aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2014-11-15 10:47:57 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2014-11-15 10:47:57 -0500
commit2bf038025274f5dd6ddaa09c5fbe0960b272d9f7 (patch)
tree5a1d7802665ef1543cb5268ed9a082f0f14a1036
parentece1052fc2e36baea8338d699166d692e681d0c0 (diff)
downloadtextadept-2bf038025274f5dd6ddaa09c5fbe0960b272d9f7.tar.gz
textadept-2bf038025274f5dd6ddaa09c5fbe0960b272d9f7.zip
Fixed command entry reset bug now that the entry is a Scintilla buffer.
-rw-r--r--modules/textadept/command_entry.lua11
-rw-r--r--src/textadept.c4
2 files changed, 12 insertions, 3 deletions
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index b4f63458..64f92c1f 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -178,7 +178,16 @@ keys.lua_command = {['\t'] = complete_lua, ['\n'] = {M.finish_mode, run_lua}}
-- Configure the command entry's default properties.
events.connect(events.INITIALIZED, function()
- if not arg then return end -- no need to reconfigure on reset
+ if not arg then
+ -- The buffers in `_BUFFERS` do not get wiped out during a reset. However,
+ -- `ui.command_entry` is not a normal buffer and does get wiped out. When
+ -- resetting, re-emit `events.BUFFER_NEW` in order to re-add buffer
+ -- functions like `set_lexer()`.
+ local buffer = _G.buffer
+ _G.buffer = M -- make event handlers believe M is the global buffer for now
+ events.emit(events.BUFFER_NEW)
+ _G.buffer = buffer
+ end
M.h_scroll_bar, M.v_scroll_bar = false, false
M.margin_width_n[0], M.margin_width_n[1], M.margin_width_n[2] = 0, 0, 0
end)
diff --git a/src/textadept.c b/src/textadept.c
index 341a5719..1105c4b1 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -152,7 +152,7 @@ TermKey *ta_tk; // global for CDK use
(focused_view ? SS(focused_view, SCI_SETFOCUS, 0, 0) : 0, \
SS(view, SCI_SETFOCUS, 1, 0))
/** Callback for refreshing a single Scintilla view. */
-static void r_cb(void *view, void*_) {scintilla_refresh((Scintilla *)view);}
+static void r_cb(void *view, void*_) { scintilla_refresh((Scintilla *)view); }
#define refresh_all() { \
wman_walk(wm, r_cb, NULL), wman_refresh(wm); \
if (command_entry_focused) scintilla_refresh(command_entry); \
@@ -1407,7 +1407,7 @@ static int lL_dofile(lua_State *L, const char *filename) {
/** `_G.reset()` Lua function. */
static int lreset(lua_State *L) {
lL_event(L, "reset_before", -1);
- lL_init(L, 0, NULL, TRUE);
+ lL_init(L, 0, NULL, TRUE), register_command_entry_doc();
l_setglobalview(L, focused_view);
l_setglobaldoc(L, SS(focused_view, SCI_GETDOCPOINTER, 0, 0));
lua_pushnil(L), lua_setglobal(L, "arg");