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.6k stars 519 forks source link

[Windows] Loosing focus by autocomplite list #1113

Closed moteus closed 2 years ago

moteus commented 3 years ago
ZeroBrane Studio (devel; MobDebug 0.706)
Copyright © 2011-2020 ZeroBrane LLC
Paul Kulchenko
Licensed under the MIT License. 
Built with wxWidgets 3.1.4, wxLua 3.0.0.8, Scintilla 3.7.2 

In this example I type a pr and after that autocomplite list shows. image

But after I type a i autocomlite list looses focus image

And in this case if I press enter a new autocomplite list creates image

pkulchenko commented 3 years ago

@moteus, I can't reproduce this. A couple of questions: 1) can you try on the current master with an empty config, and 2) do you have acandtip.strategy value set in the config?

pkulchenko commented 3 years ago

@moteus, do you still have this issue? Any additional information?

moteus commented 3 years ago

Sorry for delay. This issue still exists, but I have no time to test it with clean setup. I will reopen this issue when make more test

PS. In my config I have acandtip.strategy=2

moteus commented 2 years ago

I think I found a problem. At first I figured out that after autocomlite list shows editor stops handling idle and update ui events. Then In wxEVT_STC_PAINTED handler I found this lines. After I comment them out all start working as expected.

pkulchenko commented 2 years ago

@moteus, Interesting; thank you for the update.

I'm good with removing those if that fixes the issue for you, but I find it disappointing that I have not been able to reproduce the issue.

Can you test with editor.usewrap = false, as this is what that fragment was fixing for #250? I suspect that the issue might have been fixed in scintilla/wxwidgets already, so should be safe to remove, but would like to confirm.

moteus commented 2 years ago

I have in my config editor.usewrap = false. And when I remove it all works as expected.

moteus commented 2 years ago

Basic way to reproduce my issue is may be add e.g. ide:Print(os.time()) to wxEVT_IDLE handler. Then after autocomplite shows this print should stop writing to output

In fact when autocomplite shows output do not refresh at all as whell. Only if it resized.

pkulchenko commented 2 years ago

Then after autocomplite shows this print should stop writing to output

This is usually an indication that something fails in the event handler and is not reported (as it's happening in a different coroutine).

Can you wrap the content of the wxEVT_IDLE and wxEVT_STC_UPDATEUI handlers (and whatever else you suspect may be failing) into a pcall to see what error may be reported:

  editor:Connect(wxstc.wxEVT_STC_UPDATEUI,
    function (event)
ide:Print("UPDATEUI", pcall(function() --<-- add this line
      -- original content here
end)) --<-- add this line
    end) -- this is the end of the UPDATEUI handler

Thank you!

moteus commented 2 years ago

I wrap all editor hanlers like

  local Connect = editor.Connect
  function editor:Connect(...)
    local connect_args = {...}
    local handler = connect_args[#connect_args]
    connect_args[#connect_args] = function(...)
      local event_args = {...}
      local ok, err = pcall(function() handler(unpack(event_args)) end)
      if not ok then
        tprint{os.date('%H:%M:%S: '), connect_args[2], error = err}
      end
    end
    return Connect(self, unpack(connect_args))
  end

And there no errors Also, I found that only editor:Refresh() causes a problem. Without this call all works. Also, its possible to call EditorAutoComplete directly (not via editor:DoWhenIdle) and it also solves the problem.

pkulchenko commented 2 years ago

@moteus, should be fixed now. BTW, I was able to reproduce this issue you're describing, but only using an older version of wxwidgets (3.1), so it seems like it's been addressed/fixed in the current version (3.1.4). It's strange that it still happens for you. In any case, the original issue the workaround was for was also addressed, so removing it should be just fine now.

Thank you for the report!

moteus commented 2 years ago

My setup righ now is Built with wxWidgets 3.1.4, wxLua 3.0.0.8, Scintilla 3.7.2