aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/textadept/command_entry.lua10
-rw-r--r--src/textadept.c17
2 files changed, 11 insertions, 16 deletions
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index 800708f2..6aeef1b4 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -178,16 +178,6 @@ 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
- -- 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 0f979a13..45a6efbb 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -1424,7 +1424,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), register_command_entry_doc();
+ lL_init(L, 0, NULL, TRUE);
l_setglobalview(L, focused_view);
l_setglobaldoc(L, SS(focused_view, SCI_GETDOCPOINTER, 0, 0));
lua_pushnil(L), lua_setglobal(L, "arg");
@@ -1557,10 +1557,15 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) {
l_setcfunction(L, -1, "replace_all", lfind_replace_all);
l_setmetatable(L, -1, "ta_find", lfind__index, lfind__newindex);
lua_setfield(L, -2, "find");
- lua_newtable(L);
- l_setcfunction(L, -1, "focus", lce_focus);
- l_setcfunction(L, -1, "text_range", lbuffer_text_range);
- l_setmetatable(L, -1, "ta_buffer", lbuf_property, lbuf_property);
+ if (!reinit) {
+ lua_newtable(L);
+ l_setcfunction(L, -1, "focus", lce_focus);
+ l_setcfunction(L, -1, "text_range", lbuffer_text_range);
+ l_setmetatable(L, -1, "ta_buffer", lbuf_property, lbuf_property);
+ } else {
+ lua_getfield(L, LUA_REGISTRYINDEX, "ta_buffers");
+ lua_rawgeti(L, -1, 0), lua_replace(L, -2); // _BUFFERS[0]
+ }
lua_setfield(L, -2, "command_entry");
l_setcfunction(L, -1, "dialog", lui_dialog);
l_setcfunction(L, -1, "get_split_table", lui_get_split_table);
@@ -1727,7 +1732,7 @@ static void pane_resize(Pane *pane, int rows, int cols, int y, int x) {
/**
* Helper for unsplitting a view.
-* @param pane The pane that contains the view to unsplit.
+ * @param pane The pane that contains the view to unsplit.
* @param view The view to unsplit.
* @param parent The parent of pane. Used recursively.
* @see unsplit_view