pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.59k stars 518 forks source link

There is a problem with autocomplete #1148

Closed dfangboy closed 1 year ago

dfangboy commented 2 years ago

autocomplete:moai.lua test local m = MOAIActionTree.getRoot() local c = m:start(m) c: ---No response

pkulchenko commented 2 years ago

@dfangboy, what version of the IDE are you using? Can you test with the current master branch, as I don't see any issue there? Thank you.

dfangboy commented 2 years ago

@pkulchenko https://drive.google.com/file/d/16cVaNF93DvXgog1fNaXqxmcGLV4j-pmh/view?usp=sharing

ZeroBrane Studio (devel; MobDebug 0.802) Copyright © 2011-2021 ZeroBrane LLC Paul Kulchenko Licensed under the MIT License. Built with wxWidgets 3.1.4, wxLua 3.0.0.8, Scintilla 3.7.2 Based on Estrela Editor Copyright © 2008-2011 Luxinia DevTeam Christoph Kubisch, Eike Decker Licensed under the MIT License.

Based on wxLua editor Copyright © 2002-2005 Lomtick Software J. Winwood, John Labenski Licensed under wxWindows Library License, v3.

pkulchenko commented 2 years ago

@dfangboy, I misunderstood the initial report; I thought you meant that the app was not responding and hanging somewhere.

The process is quite simple now and doesn't really handle multiple levels of object references. I added a resolution for introduced variables, which may allow this to be handled a bit better. You can try the following patch and let me know if this works for you:

diff --git a/spec/lua.lua b/spec/lua.lua
index 8eb1cfdf..5c1e0c60 100644
--- a/spec/lua.lua
+++ b/spec/lua.lua
@@ -211,6 +211,10 @@ return {
         end

         if (var and typ) then
+          -- expand known types
+          local tbl, rest = typ:match("^(.+)(["..sep.."][^"..sep.."]+)$")
+          if tbl and assigns[tbl] then typ = assigns[tbl]..rest end
+
           if (assigns[typ] and not req) then
             assigns[var] = assigns[typ]
           else
dfangboy commented 2 years ago

@pkulchenko Perfect, thank you very much!