From edd1a1c4f1bfb976177faab9390532fe66850f47 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Mon, 11 Jul 2011 17:41:06 -0400 Subject: Allow buffer functions to omit buffer argument. This is primarily for key and menu commands to avoid creating too many unnecessary tables. --- src/textadept.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/textadept.c b/src/textadept.c index d9874dd2..661b8ca6 100644 --- a/src/textadept.c +++ b/src/textadept.c @@ -1599,8 +1599,12 @@ static int l_call_buffer_function(lua_State *lua) { int rt_type = l_rawgeti_int(lua, buffer_func_table_idx, 2); int p1_type = l_rawgeti_int(lua, buffer_func_table_idx, 3); int p2_type = l_rawgeti_int(lua, buffer_func_table_idx, 4); - l_check_focused_buffer(lua, 1); - return l_call_scintilla(lua, editor, msg, p1_type, p2_type, rt_type, 2); + int arg = 1; + if (lua_type(lua, 1) == LUA_TTABLE) { + l_check_focused_buffer(lua, 1); + arg = 2; + } + return l_call_scintilla(lua, editor, msg, p1_type, p2_type, rt_type, arg); } /** -- cgit v1.2.3