Skip to content

Commit 6a7f2ee

Browse files
committed
GUI - don't erase undo buffer history when setting text
Sonic Pi's editor calls the underlying text widget's method setText() when loading a file. This is implemented as follows: ``` // Set the given text. void QsciScintilla::setText(const QString &text) { bool ro = ensureRW(); SendScintilla(SCI_SETTEXT, ScintillaBytesConstData(textAsBytes(text))); SendScintilla(SCI_EMPTYUNDOBUFFER); setReadOnly(ro); } ``` Note that it explicitly clears the undo buffer. We override this behaviour in this commit. There's also no need to fiddle with the "read only" state. Undo now works as expected after loading a file (you can now undo and redo the load file action).
1 parent 8fffda5 commit 6a7f2ee

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

app/gui/qt/widgets/sonicpiscintilla.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,7 @@ void SonicPiScintilla::showAutoCompletion(bool val) {
680680
setAutoCompletionThreshold(-1);
681681
}
682682
}
683+
684+
void SonicPiScintilla::setText(const QString &text) {
685+
SendScintilla(SCI_SETTEXT, ScintillaBytesConstData(textAsBytes(text)));
686+
}

app/gui/qt/widgets/sonicpiscintilla.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class SonicPiScintilla : public QsciScintilla
8282
void sp_cut();
8383

8484
void showAutoCompletion(bool val);
85+
void setText(const QString &text);
8586
private:
8687
void addKeyBinding(QSettings &qs, int cmd, int key);
8788
void addOtherKeyBinding(QSettings &qs, int cmd, int key);

0 commit comments

Comments
 (0)