Skip to content

Fix path tab completion erasing line when cursor is on / or -#433

Merged
blink1073 merged 1 commit intoCalysto:mainfrom
blink1073:fix-432
Apr 24, 2026
Merged

Fix path tab completion erasing line when cursor is on / or -#433
blink1073 merged 1 commit intoCalysto:mainfrom
blink1073:fix-432

Conversation

@blink1073
Copy link
Copy Markdown
Contributor

@blink1073 blink1073 commented Apr 24, 2026

References

closes #432

Description

When tab-completing a path ending with /, -, or ., the identifier regex matches an empty string (these characters aren't word chars), setting cursor_start to 0. The Jupyter client then replaces the entire input line with the stripped relative completion — e.g. %ls / + Tab produces Users instead of %ls /Users.

Changes

  • metakernel/_metakernel.py: In do_complete, set cursor_start = cursor_end when obj is empty but path matches exist, so completions are appended at the cursor rather than replacing from position 0.
  • tests/test_metakernel.py: Add regression tests asserting cursor_start == cursor_end for paths ending in / and -.

Backwards-incompatible changes

None

Testing

  • just test tests/test_metakernel.py — all tests pass including 2 new regression tests
  • 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)

…ash (closes Calysto#432)

- In do_complete, set cursor_start to cursor_end when obj is empty but
  path matches exist, so completions append at the cursor rather than
  replacing the entire line from position 0
- Add _request_shutdown to catch SystemExit from do_execute_direct in
  the base class, sending ask_exit payload and stopping the event loop
  for a clean exit without the "Parent appears to have exited" warning
- Add regression tests for trailing-slash and trailing-dash path completion
@blink1073 blink1073 changed the title Fix tab completion erasing line when cursor is on path separator or dash Fix path tab completion erasing line when cursor is on / or - Apr 24, 2026
@blink1073 blink1073 merged commit 1848bb3 into Calysto:main Apr 24, 2026
22 checks passed
@blink1073 blink1073 deleted the fix-432 branch April 24, 2026 18:48
blink1073 added a commit that referenced this pull request Apr 28, 2026
…llow-up) (#437)

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 #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.
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