LogtalkDotOrg / logtalk-for-vscode

Logtalk for VSCode extension
MIT License
5 stars 0 forks source link

Background actions randomly trigger a new terminal #5

Closed unthingable closed 3 months ago

unthingable commented 3 months ago

Steps to reproduce:

  1. An editor with .lgt file is open
  2. Mouse over a predicate
  3. Press [cmd]

Expected: nothing

Actual: a new vscode terminal panel with Logtalk process opens and steals keyboard focus. The contents of the terminal look like this:

...
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.2-10-gf146a507d)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- logtalk_load('/usr/local/share/logtalk/coding/vscode/vscode.lgt', [scratch_directory('/Users/me/logtalk/scratch/')]).
% [ /usr/local/share/logtalk/coding/vscode/vscode.lgt loaded ]
% (0 warnings)
true.

?- vscode::find_definition('/Users/me/...', list::append/2, '/Users/me/.../hooks.lgt', 65).
true.

Additional notes:

  1. This doesn't happen every time, but often enough. Appears random (as in, I'm not seeing a pattern).
  2. Closing the terminal will just open it again next time.
  3. If terminal is left alone, the extension will reuse it and run new find_definition commands in it.

v0.20.0 Logtalk 3.78.0 SWI-Prolog (threaded, 64 bits, version 9.3.2-10-gf146a507d) MacOS 14.4.1

pmoura commented 3 months ago

Thanks for reporting. Same behavior on Windows using the control key. This seems to be default VSCode behavior:

https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition

The terminal opens as the "Go to Definition" is implemented by querying the Logtalk process. I'm yet to find a solution to disable this VSCode system behavior.

pmoura commented 3 months ago

Created https://github.com/microsoft/vscode/issues/212444. Maybe you can comment/vote on it?

unthingable commented 3 months ago

Created microsoft/vscode#212444. Maybe you can comment/vote on it?

Thanks, voted and commented.

I don't know much about vscode extensions, but it's interesting that some actions happily happen in the background without any visible terminal activity (e.g. hovering over a known predicate and seeing a documentation popup). Wonder if definitions search could be done in the background in a similar way.

pmoura commented 3 months ago

Most code navigation features (exception is go to symbol) require querying the Logtalk reflection API and thus use the terminal running the Logtalk process where the code is loaded.

Btw, a new version of the extension is expected early next week.

pmoura commented 3 months ago

Closing as opening a terminal is expected if no terminal exists and a code navigation feature that requires the code to be loaded is triggered using standard VSCode gestures. The next version of the extension improves feedback on attempts to use code navigation features (in this case, go to definition) without the required code being loaded. VSCode behavior itself may be eventually improved as per https://github.com/microsoft/vscode/issues/212444.