Skip to content

feat(core): split Extend into CoverLanding vs Span#1113

Open
kronberger-droid wants to merge 3 commits into
nushell:mainfrom
kronberger-droid:selection-extent
Open

feat(core): split Extend into CoverLanding vs Span#1113
kronberger-droid wants to merge 3 commits into
nushell:mainfrom
kronberger-droid:selection-extent

Conversation

@kronberger-droid

Copy link
Copy Markdown
Collaborator
  • New SelectionExtent (CoverLanding | Span): per-mode selection-model axis, orthogonal to CaretGeometry.
  • EditCommand::Extend branches on it:
    • vi → CoverLanding (put_cursor)
    • bar modes → Span (extend_span).
  • Cursor::extend_span: grows a Span to gap-indexed op_end, no vi-visual widening
  • Both placement strategies funnel through Editor::place (set_cursor + commit_cursor).

Why

  • Splits where the caret rests (geometry) from how far a motion drags the head (extent).
  • Span is Helix groundwork, since no current mode pairs Block + Span, so that reversal path is exercised by unit tests only.

Tests

  • extend_span units incl. the Helix-bound block-reversal flip.
  • Successive emacs Extend(w) grows the Span.

Notes

  • No public API change (all pub(crate)).
  • Fully behavior preserving.
  • fmt + clippy --all-targets clean; full suite green.

kronberger-droid and others added 2 commits June 29, 2026 14:43
- SelectionExtent axis chosen per edit mode (vi -> CoverLanding,
  bar modes -> Span); orthogonal to CaretGeometry
- Cursor::extend_span grows a Span without vi-visual widening,
  sharing flip_anchor (extracted from put_cursor) on reversal
- funnel both placement strategies through Editor::place
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@u-k-g

u-k-g commented Jul 18, 2026

Copy link
Copy Markdown

tested on aarch64-darwin with cargo test --all-features -- --test-threads=1: 1,216 tests passed. The Helix example also builds and runs.

cargo test --all-features -- --test-threads=1; cargo run --example helix --features helix
$ cargo test --all-features -- --test-threads=1; cargo run --example helix --features helix

Finished `test` profile [unoptimized + debuginfo] target(s) in 0.06s
Running unittests src/lib.rs (target/debug/deps/reedline-f3d584acdddd1871)

running 1217 tests
<redacted due to verbosity>

test result: ok. 1216 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.09s

Doc-tests reedline

running 29 tests
<redacted due to verbosity>

test result: ok. 29 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 8.89s

Compiling crossterm v0.29.0
Compiling reedline v0.48.0 (/Users/uzair/01-projects/reedline)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.42s
test src/menu/menu_functions.rs - menu::menu_functions::string_difference (line 207) ... ok

test result: ok. 29 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 8.89s

Compiling crossterm v0.29.0
Compiling reedline v0.48.0 (/Users/uzair/01-projects/reedline)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.42s
Running `target/debug/examples/helix`
Helix edit mode demo:
Default mode is insert (`:` prompt), so you can type words.
Press Esc for normal mode.
Press `i` to return to insert mode, or `a` to insert after the current selection.
Only `h`/`l` motions are currently implemented.
Abort with Ctrl-C
~/01-projects/reedline: helix test.

Aborted!

- extend_span_block_flip_hops_full_multibyte_grapheme: exercise the new
  extend_span entry into flip_anchor with a 2-byte anchor grapheme (café's
  é), proving it hops the whole grapheme like put_cursor does.
- selection_extent_maps_...: pin the PromptEditMode -> SelectionExtent
  dispatch table directly (vi -> CoverLanding, bar modes -> Span).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants