Conversation
Tab completion ran completion("obj") directly and parsed Scilab's own
console echo of the result. That echo used to be an unquoted, bracketed
format Scilab dropped at least ~2 years ago in favor of displaying
string arrays quoted (`"a" "b" ...`), which the parsing here was
never updated for -- so every completion candidate now comes back
wrapped in literal double quotes.
Fixed by using printf("%s\n", completion(...)) instead, which prints
each match bare, one per line, sidestepping Scilab's own display
formatting entirely (and the quoting behind whatever future formatting
changes might come). Two things needed care:
- printf errors out on an empty array, so it's now only called when
completion() isn't empty (checked without assigning the result to a
variable -- get_completions() runs in the same persistent Scilab
session as the user's own code, so nothing here should risk shadowing
a variable of theirs).
- Scilab's terminal control codes end up glued to the front of the
*first* line of any console output. With the old quoted/bracketed
format this only ever landed on a line that got filtered out by
coincidence; with printf's plain output it could leak into a real
match (reproduced with a single-match completion, e.g. "getscilabkeyword"
-> "\x1b[4l \x08\x1b[0mgetscilabkeywords" instead of
"getscilabkeywords"). Now stripped via a small regex before parsing.
Verified against a live kernel: multi-match, single-match, and
no-match completions all return clean results, and `who_user()`
confirms nothing gets left behind in the session.
Also includes the same pre-existing ruff cleanup as PR Calysto#58 (this
branch was cut from master, which still has it) -- see that PR's
commit message for the itemized list; same fixes, same reasoning.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
6 tasks done
Contributor
Author
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tab completion in a notebook cell ran
completion(\"obj\")directly and parsed Scilab's own console echo of the result. That echo used to be an unquoted, bracketed format Scilab dropped at least ~2 years ago in favor of displaying string arrays quoted ("a" "b" ...), which the parsing here was never updated for — so every completion candidate comes back wrapped in literal double quotes, and (per the original report) the old fallback also used to open the JavaHelp browser as a side effect on some versions.Fixed by using
printf("%s\n", completion(...))instead, which prints each match bare, one per line, sidestepping Scilab's own display formatting entirely.Two things needed care:
printferrors out on an empty array, so it's only called whencompletion()isn't empty — checked without ever assigning the result to a variable, sinceget_completions()runs in the same persistent Scilab session as the user's own code, and a temp variable could shadow one of theirs.info['obj']); withprintf's plain output it could leak into a real match — reproduced with a single-match completion (e.g."getscilabkeyword"returned"\x1b[4l \x08\x1b[0mgetscilabkeywords"instead of"getscilabkeywords"). Now stripped via a small regex before parsing.Also includes the same pre-existing ruff cleanup as #58 (this branch was cut from
master, which still has that debt) — CI was failing on unrelated pre-existing findings before this cleanup, same as described there.Test plan
"plo"), single-match ("getscilabkeyword"), and no-match ("zzzzzz") completions all return clean, unquoted results.who_user()that nothing is left behind in the Scilab session after completion runs.ruff check .clean, all filespy_compile, kernel smoke-tested (disp,%plotproducing real output).🤖 Generated with Claude Code