From 87406bc00d6335acaff0d328985bd4ded6edf1c2 Mon Sep 17 00:00:00 2001 From: Wojbie Date: Fri, 7 Jul 2017 02:30:57 +0200 Subject: [PATCH] Tweak to Colon syntax lua autocompletition. Changes autocompletition to only complete function names (Or table names treated as functions via __call metamethod) after the colon symbol. --- .../computercraft/lua/rom/apis/textutils.lua | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua b/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua index a160f4b7f..a553c623c 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua @@ -409,12 +409,23 @@ function complete( sSearchText, tSearchTable ) if string.find( k, sPart, 1, true ) == 1 then if not g_tLuaKeywords[k] and string.match( k, "^[%a_][%a%d_]*$" ) then local sResult = string.sub( k, nPartLength + 1 ) - if type(v) == "function" then - sResult = sResult .. "(" - elseif type(v) == "table" and next(v) ~= nil then - sResult = sResult .. "." + if nColon then + if type(v) == "function" then + table.insert( tResults, sResult .. "(" ) + elseif type(v) == "table" then + local tMetatable = getmetatable( v ) + if tMetatable and ( type( tMetatable.__call ) == "function" or type( tMetatable.__call ) == "table" ) then + table.insert( tResults, sResult .. "(" ) + end + end + else + if type(v) == "function" then + sResult = sResult .. "(" + elseif type(v) == "table" and next(v) ~= nil then + sResult = sResult .. "." + end + table.insert( tResults, sResult ) end - table.insert( tResults, sResult ) end end end