diff options
author | mitchell <unknown> | 2018-03-25 16:33:56 -0400 |
---|---|---|
committer | mitchell <unknown> | 2018-03-25 16:33:56 -0400 |
commit | be57d5a4e5a12886bcb9aee9d131889863b7ea5f (patch) | |
tree | bc5edba4d3cf90d5992d4e864e21d01bd19d7252 | |
parent | 7a286ce48368d0232dea713d0b9a989edb30d3a7 (diff) | |
download | scintilla-mirror-be57d5a4e5a12886bcb9aee9d131889863b7ea5f.tar.gz |
Fixed LPeg lexer incorrectly applying style changes to stale property sets.
Also, when manually updating the default style, call SCI_STYLECLEARALL in order
for subsequent style updates to inherit from the default style.
-rw-r--r-- | lexers/LexLPeg.cxx | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lexers/LexLPeg.cxx b/lexers/LexLPeg.cxx index fe4749f60..9ab8a5c8a 100644 --- a/lexers/LexLPeg.cxx +++ b/lexers/LexLPeg.cxx @@ -93,8 +93,6 @@ class LexerLPeg : public ILexer { * The set of properties for the lexer. * The `lexer.name`, `lexer.lpeg.home`, and `lexer.lpeg.color.theme` * properties must be defined before running the lexer. - * For use with SciTE, all of the style property strings generated for the - * current lexer are placed in here. */ PropSetSimple props; /** The function to send Scintilla messages with. */ @@ -312,8 +310,7 @@ class LexerLPeg : public ILexer { /** * Iterates through the lexer's `_TOKENSTYLES`, setting the style properties - * for all defined styles, or for SciTE, generates the set of style properties - * instead of directly setting style properties. + * for all defined styles. */ bool SetStyles() { // If the lexer defines additional styles, set their properties first (if @@ -674,11 +671,19 @@ public: if (reinit) Init(); else if (L && SS && sci && strncmp(key, "style.", 6) == 0) { + lua_pushlightuserdata(L, reinterpret_cast<void *>(&props)); + lua_setfield(L, LUA_REGISTRYINDEX, "sci_props"); l_getlexerfield(L, "_TOKENSTYLES"); lua_pushstring(L, key + 6), lua_rawget(L, -2); lua_pushstring(L, key), lL_getexpanded(L, -1), lua_replace(L, -2); - if (lua_isnumber(L, -2)) - SetStyle(lua_tointeger(L, -2), lua_tostring(L, -1)); + if (lua_isnumber(L, -2)) { + int style_num = lua_tointeger(L, -2); + SetStyle(style_num, lua_tostring(L, -1)); + if (style_num == STYLE_DEFAULT) + // Assume a theme change, with the default style being set first. + // Subsequent style settings will be based on the default. + SS(sci, SCI_STYLECLEARALL, 0, 0); + } lua_pop(L, 3); // style, style number, _TOKENSTYLES } return -1; // no need to re-lex |