Skip to content

Lambe 0.6.2: completer replacement range (start + end); man-page polish#3

Closed
hakimjonas wants to merge 2 commits into
mainfrom
fix/completer-replacement-range
Closed

Lambe 0.6.2: completer replacement range (start + end); man-page polish#3
hakimjonas wants to merge 2 commits into
mainfrom
fix/completer-replacement-range

Conversation

@hakimjonas
Copy link
Copy Markdown
Owner

The Completions typedef now carries both start and end, so callers can splice a candidate over the typed token only and preserve any trailing whitespace the user typed between the token and the cursor.

Breaking: Completions gains a required end field.

Before 0.6.2, accepting a completion with trailing whitespace between the token and the cursor silently erased that whitespace. A user who typed .users and added a space (intending to start a pipe expression next) would see the space disappear on Tab. The library's contract conflated "where to place the candidate" with "how much text to replace." The new end field separates them.

Completer changes (lib/src/completer.dart):

  • Completions typedef: (start, end, candidates); end is the position just past the last non-whitespace char of the partial token.
  • All 8 return sites updated to compute end correctly.
  • Empty-candidates bailouts return start == end == cursor so the UI knows nothing needs replacing.

Readline changes (lib/src/readline.dart):

  • CompleteCallback typedef updated.
  • _tab() splices with text.replaceRange(start, end, ...) instead of replacing up to cursor.

Tests: 18 new tests in Replacement range (start/end contract) group, including a splice-semantics test that verifies
text.replaceRange(start, end, candidate) preserves trailing whitespace. Total 770 tests passing (was 752 at 0.6.1).

Man page (doc/lam.1.md):

  • Version bumped to 0.6.2 in frontmatter.
  • DESCRIPTION now mentions shape-awareness; points at --explain and as(fmt) for follow-up reading.
  • OPTIONS: --explain added between --schema and --assert.
  • PIPELINE OPERATIONS: to_number, type, as(fmt) added (previously missing despite being 0.6.0 features).
  • EXAMPLES: shape trace (--explain) and in-query bridge (as(toml)).
  • SEE ALSO restructured: jq framing is respectful ("the established JSON query tool; Lambe shares its pipeline aesthetic"), with dedicated BUGS and HOMEPAGE sections. URLs use CommonMark autolinks so they render as real anchors, not plain text.

Version metadata:

  • pubspec.yaml 0.6.1 -> 0.6.2.
  • lib/src/_version.dart regenerated.
  • doc/lam.1 regenerated from the updated markdown source.

Release gate: format, analyze --fatal-infos, dart doc --dry-run, tests all clean.

hakimjonas added 2 commits May 1, 2026 00:33
The Completions typedef now carries both start and end, so callers
can splice a candidate over the typed token only and preserve any
trailing whitespace the user typed between the token and the cursor.

Breaking: Completions gains a required `end` field.

Before 0.6.2, accepting a completion with trailing whitespace
between the token and the cursor silently erased that whitespace.
A user who typed `.users` and added a space (intending to start a
pipe expression next) would see the space disappear on Tab. The
library's contract conflated "where to place the candidate" with
"how much text to replace." The new `end` field separates them.

Completer changes (lib/src/completer.dart):
- Completions typedef: (start, end, candidates); end is the position
  just past the last non-whitespace char of the partial token.
- All 8 return sites updated to compute end correctly.
- Empty-candidates bailouts return start == end == cursor so the UI
  knows nothing needs replacing.

Readline changes (lib/src/readline.dart):
- CompleteCallback typedef updated.
- _tab() splices with text.replaceRange(start, end, ...) instead of
  replacing up to cursor.

Tests: 18 new tests in `Replacement range (start/end contract)` group,
including a splice-semantics test that verifies
text.replaceRange(start, end, candidate) preserves trailing whitespace.
Total 770 tests passing (was 752 at 0.6.1).

Man page (doc/lam.1.md):
- Version bumped to 0.6.2 in frontmatter.
- DESCRIPTION now mentions shape-awareness; points at --explain and
  as(fmt) for follow-up reading.
- OPTIONS: --explain added between --schema and --assert.
- PIPELINE OPERATIONS: to_number, type, as(fmt) added (previously
  missing despite being 0.6.0 features).
- EXAMPLES: shape trace (--explain) and in-query bridge (as(toml)).
- SEE ALSO restructured: jq framing is respectful ("the established
  JSON query tool; Lambe shares its pipeline aesthetic"), with
  dedicated BUGS and HOMEPAGE sections. URLs use CommonMark autolinks
  so they render as real <a> anchors, not plain text.

Version metadata:
- pubspec.yaml 0.6.1 -> 0.6.2.
- lib/src/_version.dart regenerated.
- doc/lam.1 regenerated from the updated markdown source.

Release gate: format, analyze --fatal-infos, dart doc --dry-run, tests
all clean.
Candidates whose value equals the text already present in [start, end)
are stripped before returning. Accepting such a candidate is a no-op
on the text and would only move the cursor backward.

For .dependencies jd + Tab, the completer previously returned
.dependencies as a candidate. Accepting it left the text unchanged
but snapped the cursor from position 16 back to position 13, which
reads as "the tool erased what I typed." Tab is now a silent no-op in
this case, matching the behavior of other Tab-completion UIs.

Changes:
- lib/src/completer.dart: complete() now wraps _completeRaw() with a
  filter pass that drops any candidate equal to text.substring(start, end).
- test/completer_test.dart: existing tests updated to reflect the new
  behavior (9 in the "Trailing whitespace regression" group, the :q
  command test, and the splice-semantics test). New "Re-assertion
  filter" group with 7 tests covering the fully-typed / partial /
  multiple-match cases. 778 tests total, all passing.
- CHANGELOG.md: 0.6.2 entry mentions the filter.
@hakimjonas
Copy link
Copy Markdown
Owner Author

Superseded by the upcoming 0.7.0 PR.

0.6.2 was never published to pub.dev. The completer replacement-range
fix and re-assertion filter from this PR are rolled into 0.7.0, which
also ships the spec-driven pipe-op metadata refactor and shape-gated
completion. See the release/0.7.0 branch.

@hakimjonas hakimjonas closed this May 1, 2026
@hakimjonas hakimjonas mentioned this pull request May 1, 2026
10 tasks
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.

1 participant