Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/editor/TextEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,6 @@ TextEditor::TextEditor(QWidget *parent) : ScintillaEdit(parent) {
LuaAdded = true;
}

// Every editor needs its own lexer instance: unlike a classic Scintilla
// lexer, Scintillua's ILexer5 is stateful (it tracks the currently
// detected language), so it can't be shared between editors.
ILexer5 *lua = CreateLexer("lua");
if (lua) {
setILexer((sptr_t)lua);
} else {
qWarning() << "Error creating Lua lexer";
}

setScrollWidth(256);
setScrollWidthTracking(true);
setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
Expand Down Expand Up @@ -294,10 +284,17 @@ void TextEditor::applySettings() {
loadMarkerPixmap(StagedMarker, mStagedIcon);
loadMarkerPixmap(UnstagedMarker, mUnStagedIcon);

// Set LPeg lexer language.
QByteArray lexer = this->lexer().toUtf8();
uintptr_t ptr = reinterpret_cast<uintptr_t>(lexer.constData());
privateLexerCall(SCLUA_DETECT, ptr);
// A Scintillua lexer's language is fixed at creation, so replace it when the
// language changes.
QString lexerName = lexer();
if (lexerName != mLexerName) {
mLexerName = lexerName;
ILexer5 *instance = CreateLexer(lexerName.toUtf8().constData());
if (!instance)
qWarning() << "Error creating lexer" << lexerName << ":"
<< GetCreateLexerError();
setILexer(reinterpret_cast<sptr_t>(instance));
}

// Re-apply theme colors: the set of named styles is lexer-dependent and
// may have just changed.
Expand Down
1 change: 1 addition & 0 deletions src/editor/TextEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class TextEditor : public ScintillaEdit {
void applyLexerStyles();

QString mPath;
QString mLexerName;
int mLineCount = -1;
/*!
* statusDiff Flag which determines if in the contextmenu stage actions are
Expand Down
Loading