mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Fix duplicated newline on save (windows)
This commit is contained in:
parent
d1edbc8fdf
commit
1f25b41d79
@ -301,7 +301,9 @@ class Editor(QgsCodeEditorPython):
|
||||
|
||||
def createTempFile(self):
|
||||
name = tempfile.NamedTemporaryFile(delete=False).name
|
||||
Path(name).write_text(self.text(), encoding='utf-8')
|
||||
# Need to use newline='' to avoid adding extra \r characters on Windows
|
||||
with open(name, 'w', encoding='utf-8', newline='') as f:
|
||||
f.write(self.text())
|
||||
return name
|
||||
|
||||
def runScriptCode(self):
|
||||
@ -427,7 +429,9 @@ class Editor(QgsCodeEditorPython):
|
||||
self.pythonconsole.callWidgetMessageBarEditor(msgText, 0, True)
|
||||
|
||||
# Save the new contents
|
||||
Path(self.path).write_text(self.text(), encoding='utf-8')
|
||||
# Need to use newline='' to avoid adding extra \r characters on Windows
|
||||
with open(self.path, 'w', encoding='utf-8', newline='') as f:
|
||||
f.write(self.text())
|
||||
tabwidget.setTabTitle(index, Path(self.path).name)
|
||||
tabwidget.setTabToolTip(index, self.path)
|
||||
self.setModified(False)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user