Skip to content

Commit 00faa2d

Browse files
committed
Fixed a regression on automatic file reloading when an external editor was used
1 parent f9beae7 commit 00faa2d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cq_editor/widgets/editor.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from spyder.plugins.editor.widgets.codeeditor import CodeEditor
66
from PyQt5.QtCore import pyqtSignal, QFileSystemWatcher, QTimer
7-
from PyQt5.QtWidgets import QAction, QFileDialog
7+
from PyQt5.QtWidgets import QAction, QFileDialog, QApplication
88
from PyQt5.QtGui import QFontDatabase, QTextCursor
99
from path import Path
1010

@@ -284,13 +284,15 @@ def _file_changed(self):
284284
cursor.select(QTextCursor.Document)
285285
cursor.insertText(file_contents)
286286

287+
# The editor will not always update after a text insertion, so we force it
288+
QApplication.processEvents()
289+
287290
# Stop blocking signals
288291
self.blockSignals(False)
289292

290293
# Restore undo stack availability
291294
if undo_stack:
292295
self.document().setModified(True)
293-
self.document().undo() # Prevents the need for a double undo
294296

295297
# Restore the cursor position and selection
296298
cursor.setPosition(anchor_position)

0 commit comments

Comments
 (0)