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

Selected special symbol in the command bar #1053

Closed moteus closed 4 years ago

moteus commented 4 years ago

On the Ubuntu system when open command bar like navigate to line or function, first special character (: or @) becomes selected, and when I try to type a line number or function name I replace it and I switched to navigate to file mode.

I have no such problem on the Windows systme

pkulchenko commented 4 years ago

Yes, there is some weirdness going on with this handling on linux, so I added some Linux-specific workarounds in the past; for example, see https://github.com/pkulchenko/ZeroBraneStudio/blob/master/src/editor/commandbar.lua#L306-L308. I'll check if this workaround needs to be extended to other cases.

Can you describe the scenario in a bit more detail? For example, when you type : and then 1; are you saying that :1 becomes selected, so when you type 2, it replaces what was selected?

moteus commented 4 years ago

image This is what happened when I press Gtrl+G. So if I type a digit 1 I replace a : symbol.

pkulchenko commented 4 years ago

@moteus, can you check the following patch?

diff --git a/src/editor/commandbar.lua b/src/editor/commandbar.lua
index 691d8704..7fa9a8dd 100644
--- a/src/editor/commandbar.lua
+++ b/src/editor/commandbar.lua
@@ -340,8 +340,8 @@ local function showCommandBar(params)
   frame:Refresh()

   search:SetValue((defaultText or "")..(selectedText or ""))
-  search:SetSelection(#(defaultText or ""), -1)
   search:SetFocus()
+  search:SetSelection(#(defaultText or ""), -1)
 end

 local sep = "[/\\%-_ ]+"

It fixes the issue for me (and doesn't change the behavior on Windows), but would like to confirm before applying. It looks like there is some strangeness with the order of calls on Linux, but this sequence should produce the correct result.

moteus commented 4 years ago

Yes. It works for me too.