Skip to content

fix: extend cursor_start fix to magic get_completions (issue #432 follow-up)#437

Merged
blink1073 merged 1 commit intoCalysto:mainfrom
blink1073:fix-432-magic-completions
Apr 28, 2026
Merged

fix: extend cursor_start fix to magic get_completions (issue #432 follow-up)#437
blink1073 merged 1 commit intoCalysto:mainfrom
blink1073:fix-432-magic-completions

Conversation

@blink1073
Copy link
Copy Markdown
Contributor

References

closes #432 (follow-up to #433)

Description

The v1.0.3 fix in #433 corrected cursor_start for path completions when the cursor sits after a non-identifier character (e.g. /, -). However, when a magic's get_completions returns matches in the same situation (e.g. cursor after --), cursor_start was still left at 0, causing the Jupyter client to erase and replace the entire input line.

Changes

  • metakernel/_metakernel.py: At the end of do_complete, after all matches are collected, apply the same fix: when info["obj"] is empty and there are matches, set cursor_start = cursor_end so completions are appended at the cursor rather than replacing from position 0.
  • tests/test_metakernel.py: Add test_magic_complete_trailing_dash — registers a custom magic with get_completions returning options, and asserts that for %option_magic --, cursor_start == cursor_end.

Backwards-incompatible changes

None

Testing

  • just test tests/test_metakernel.py — all 93 tests pass including the new regression test
  • just typing — no issues
  • just pre-commit — all hooks pass

AI usage

  • Some or all of the content of this PR was generated by AI.
  • The human author has carefully reviewed this PR and run this code.
  • AI tools and models used: Claude Sonnet 4.6 (Claude Code)

…#432 follow-up)

When a magic's get_completions returns matches and the cursor sits after a
non-identifier character such as '--', cursor_start was still left at 0,
causing the client to erase and replace the entire input line.

Apply the same fix used for path completions (PR Calysto#433): when info["obj"] is
empty and there are matches at the end of do_complete, set cursor_start to
cursor_end so completions are appended at the cursor rather than replacing
from position 0.

Add test_magic_complete_trailing_dash to cover this case with a custom magic
that offers completions for a '--' prefix.
@blink1073 blink1073 added the bug label Apr 28, 2026
@blink1073 blink1073 merged commit 68ebee9 into Calysto:main Apr 28, 2026
22 checks passed
@blink1073 blink1073 deleted the fix-432-magic-completions branch April 28, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Path completion starts as 0 when current path ends with / or -

1 participant