Skip to content
Snippets Groups Projects
Unverified Commit 4cb3f06c authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony Committed by GitHub
Browse files

Merge pull request #27936 from mantidproject/27558_double_spacing_on_save

Fix workbench double-spacing on saving Python scripts on Windows 
parents 4bda7a40 732cd5a5
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,7 @@ Improvements
- The context menu for WorkspaceGroups now contains plotting options so you can plot all of the workspaces in the group.
- Most changes in the settings dialog now take place immediately, no longer needing a restart, such as hiding algorithm categories, interfaces or choosing wether to see invisible workspaces.
- A warning now appears if you attempt to plot more than ten spectra.
- Toggle Whitespace in the editor now shows line endings as well as spaces and tabs
- The Save menu action in the workspaces toolbox to save using version 1 of the SaveAscii algorithm has been removed as no one was using it and it only added confusion. The option to save using the most recent version of SaveASCII is still available.
- You can now search for functions when doing fits.
- A help button has been added to the fitting add function dialog.
......@@ -44,6 +45,7 @@ Improvements
Bugfixes
########
- Fixed an issue with Workspace History where unrolling consecutive workflow algorithms would result in only one of the algorithms being unrolled.
- Workbench now saves python files properly on windows and does not double up on line feed characters.
- Fixed a couple of errors in the python scripts generated from plots for newer versions of Matplotlib.
- Colorbar scale no longer vanish on colorfill plots with a logarithmic scale
- Figure options no longer causes a crash when using 2d plots created from a script.
......
......@@ -11,6 +11,8 @@ from __future__ import (absolute_import, unicode_literals)
# system imports
import os.path as osp
import os
import sys
# third-party library imports
from qtpy.QtWidgets import QVBoxLayout
......@@ -25,17 +27,18 @@ from ..plugins.base import PluginWidget
# Initial content
DEFAULT_CONTENT = """# The following line helps with future compatibility with Python 3
# print must now be used as a function, e.g print('Hello','World')
from __future__ import (absolute_import, division, print_function, unicode_literals)
DEFAULT_CONTENT = ""
if sys.version_info < (3,0):
DEFAULT_CONTENT += "# The following line helps with future compatibility with Python 3" + os.linesep + \
"# print must now be used as a function, e.g print('Hello','World')" + os.linesep + \
"from __future__ import (absolute_import, division, print_function, unicode_literals)" + \
os.linesep + os.linesep
DEFAULT_CONTENT += "# import mantid algorithms, numpy and matplotlib" + os.linesep + \
"from mantid.simpleapi import *" + os.linesep + \
"import matplotlib.pyplot as plt" + os.linesep + \
"import numpy as np" + os.linesep + os.linesep
# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
"""
# Accepted extensions for drag-and-drop to editor
ACCEPTED_FILE_EXTENSIONS = ['.py', '.pyw']
# QSettings key for session tabs
......
......@@ -175,6 +175,7 @@ public:
void setSelection(int lineFrom, int indexFrom, int lineTo, int indexTo);
void setTabWidth(int width);
void setText(const QString &text);
void setEolVisibility(bool state);
void setWhitespaceVisibility(WhitespaceVisibility mode);
void updateCompletionAPI(const QStringList & completions);
......
......@@ -95,7 +95,7 @@ class EditorIO(object):
self.editor.setFileName(filename)
try:
with io.open(filename, 'w', encoding='utf8') as f:
with io.open(filename, 'w', encoding='utf8', newline='') as f:
f.write(self.editor.text())
self.editor.setModified(False)
except IOError as exc:
......@@ -225,9 +225,11 @@ class PythonFileInterpreter(QWidget):
self.replace_text(SPACE_CHAR * TAB_WIDTH, TAB_CHAR)
def set_whitespace_visible(self):
self.editor.setEolVisibility(True)
self.editor.setWhitespaceVisibility(CodeEditor.WsVisible)
def set_whitespace_invisible(self):
self.editor.setEolVisibility(False)
self.editor.setWhitespaceVisibility(CodeEditor.WsInvisible)
def toggle_comment(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment