Closed paaguti closed 1 year ago
Textadept does not emit events.BUFFER_AFTER_SWITCH
after events.BUFFER_NEW
(the latter implies the former). What you are seeing is a side-effect of closing an initial empty buffer when opening a Python file (https://github.com/orbitalquark/textadept/blob/c210f2bd184d78245a7be4b6c6ebb1849c6697d3/core/file_io.lua#L308-L313). If you start Textadept, type into the empty buffer, and then attempt to open a Python file, you will not see an events.BUFFER_AFTER_SWITCH
event.
I know this was intentional, but I don't exactly remember the rationale, so I'm not certain this is a bug.
I've found a workaround: I connect to events.LEXER_LOADED
events.FILE_OPENED
and events.BUFFER_AFTER_SWITCH
and I get the lexer with view.buffer.lexer_language
and I don't seem to miss anything right now.
I'm happy with my current workaround. Close this if you have something more urgent.
On the latest nightly (Qt) tested on Linux (self-compiled) and WIndows (downloaded from github) I'm tracking BUFFER_NEW and BUFFER_AFTER_SWITCH and when they are emitted, I print
view.buffer.lexer_language
. withThe sequence of actions is 1.- Call textadept to edit a Python File and then 2.- Open the preferences
I'm missing a final
BUFFER_AFTER_SWITCH ->lua
when~/.textadept/init.lua
is opened.