feat: save visual selections as range annotations #128

Merged
noe.trevino merged 11 commits from feature-108/range-persistence into feature-108/visual-selection-annotations 2026-10-13 18:23:43 -05:00
Owner

Stacked on #127.

  • store an optional end_line on bookmarks (storage stays v2)
  • track the range with one ranged extmark; the end anchors at col 0 of the next line
  • sync end_line from the extmark on every read
  • annotate(text, { line1, line2 })
  • annotate the Visual selection (v, V, CTRL-V)
  • :'<,'>HauntAnnotate
  • tests: undoing a whole-range delete brings the range back; Visual mode driven through a <Plug> mapping

Cleanup from review:

  • one "is a range" rule (normalize_end_line), applied where bookmarks enter
  • a range starting past the end of the buffer gets a clear error
  • get_extmark_line reuses get_extmark_range
  • specs use the shared helpers

Not in this PR: drawing ranges differently, and finding a range from lines inside it.

  • tests pass (565)

Refs #108

Stacked on #127. - store an optional `end_line` on bookmarks (storage stays v2) - track the range with one ranged extmark; the end anchors at col 0 of the next line - sync `end_line` from the extmark on every read - `annotate(text, { line1, line2 })` - annotate the Visual selection (v, V, CTRL-V) - `:'<,'>HauntAnnotate` - tests: undoing a whole-range delete brings the range back; Visual mode driven through a `<Plug>` mapping Cleanup from review: - one "is a range" rule (`normalize_end_line`), applied where bookmarks enter - a range starting past the end of the buffer gets a clear error - `get_extmark_line` reuses `get_extmark_range` - specs use the shared helpers Not in this PR: drawing ranges differently, and finding a range from lines inside it. - [x] tests pass (565) Refs #108
- add an end_line param to create_bookmark
- add an end_line field to the Bookmark object
- reject an end_line before line in is_valid_bookmark
- only serialize end_line for ranges

Refs #108
- end range extmarks at col 0 of the line after the range
- add get_extmark_range to read the range back
- clamp the end so it never falls before the start

Refs #108
- read each bookmark's range from its extmark on sync
- tests: undoing a whole-range delete brings the range back

Refs #108
- add an optional range param to annotate
- order and clamp the range to the buffer
- pass end_line through to create_bookmark

Refs #108
- take the range from the Visual selection (v, V, CTRL-V)
- leave Visual mode before prompting
- tests: drive Visual mode through a <Plug> mapping

Refs #108
feat(commands): accept a range on :HauntAnnotate
All checks were successful
Auto Assign / assign (pull_request_target) Successful in 1s
CI / config (pull_request) Successful in 4s
CI / stylua (pull_request) Successful in 6s
CI / Check for debug messages (pull_request) Successful in 4s
CI / tests (pull_request) Successful in 14s
CI / docs (pull_request) Has been skipped
CI / release (pull_request) Has been skipped
CI / ci (pull_request) Successful in 0s
4b5ac2a5a1
- add range to the HauntAnnotate command
- pass line1/line2 through to annotate

Refs #108
- return a nil end from get_extmark_range when the end is not past the start
- read get_extmark_line through get_extmark_range
- store the synced end as-is

Refs #108
- add normalize_end_line as the one "is a range" rule
- normalize end_line in create_bookmark and on load
- test end_line ~= nil in set_bookmark_mark and _build_serializable

Refs #108
- add normalize_range to order and clamp a line range in one place
- reject a range whose start is past the last line with an error notify
- return the raw selection ends from take_visual_range

Refs #108
- compute the command text and range once for has_args commands

Refs #108
test: use the shared helpers in the range specs
All checks were successful
CI / Check for debug messages (pull_request) Successful in 4s
CI / stylua (pull_request) Successful in 6s
CI / config (pull_request) Successful in 7s
CI / tests (pull_request) Successful in 18s
CI / docs (pull_request) Has been skipped
CI / release (pull_request) Has been skipped
CI / ci (pull_request) Successful in 0s
79030be3d0
- read the saved file with helpers.read_bookmarks_file in api_spec
- build and clean up the range sync buffer with helpers in store_spec

Refs #108
Author
Owner

@smith this is a test. say hi

@smith this is a test. say hi
Author
Owner

@smith test again, say hello

@smith test again, say hello
Collaborator

Good evening, Mr. Trevino.

Hello. Your message arrived intact, and so did the one before it. I changed no files.

Run

Good evening, Mr. Trevino. Hello. Your message arrived intact, and so did the one before it. I changed no files. <sub>[Run](https://git.thenoetrevino.com/noe.trevino/ci/actions/runs/41)</sub>
noe.trevino merged commit 7b593d08b6 into feature-108/visual-selection-annotations 2026-10-13 18:23:43 -05:00
Sign in to join this conversation.
No description provided.