aboutsummaryrefslogtreecommitdiffhomepage
path: root/init.lua
diff options
context:
space:
mode:
authorGravatar mitchell <70453897+667e-11@users.noreply.github.com>2020-03-16 10:52:02 -0400
committerGravatar mitchell <70453897+667e-11@users.noreply.github.com>2020-03-16 10:52:02 -0400
commit1d5069fec0d41c5370438b6c253d6ba71b528797 (patch)
treef2e1cd03d579849be8b591345b0f7937541fe670 /init.lua
parent7915ceff37bdb16215e85b821e2b2e2ba2c2f288 (diff)
Fixed crash introduced in previous commit.
The assumption was that `buffer.set_lexer` is only unavailable for the first buffer, which has `buffer:private_lexer_call(SETLEXERLANGUAGE, ...)` called in the `events.BUFFER_NEW` handler. However, `reset()` throws a wrench into everything and a buffer can end up without a lexer.
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 19079025..d367fab3 100644
--- a/init.lua
+++ b/init.lua
@@ -31,7 +31,9 @@ local function set_theme(buffer, name, props)
for prop, value in pairs(props) do buffer.property[prop] = value end
-- Force reload of all styles since the current lexer may have defined its own
-- styles. (The LPeg lexer has only refreshed default lexer styles.)
- if buffer.set_lexer then buffer:set_lexer(buffer._lexer or 'text') end
+ -- Note: cannot use `buffer.set_lexer()` because it may not exist yet.
+ local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2]
+ buffer:private_lexer_call(SETLEXERLANGUAGE, buffer._lexer or 'text')
end
events.connect(events.BUFFER_NEW, function() buffer.set_theme = set_theme end)
buffer.set_theme = set_theme -- needed for the first buffer