Lambe 0.6.2: completer replacement range (start + end); man-page polish#3
Closed
hakimjonas wants to merge 2 commits into
Closed
Lambe 0.6.2: completer replacement range (start + end); man-page polish#3hakimjonas wants to merge 2 commits into
hakimjonas wants to merge 2 commits into
Conversation
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.
Owner
Author
|
Superseded by the upcoming 0.7.0 PR. 0.6.2 was never published to pub.dev. The completer replacement-range |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
endfield.Before 0.6.2, accepting a completion with trailing whitespace between the token and the cursor silently erased that whitespace. A user who typed
.usersand 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 newendfield separates them.Completer changes (lib/src/completer.dart):
Readline changes (lib/src/readline.dart):
Tests: 18 new tests in
Replacement range (start/end contract)group, including a splice-semantics test that verifiestext.replaceRange(start, end, candidate) preserves trailing whitespace. Total 770 tests passing (was 752 at 0.6.1).
Man page (doc/lam.1.md):
Version metadata:
Release gate: format, analyze --fatal-infos, dart doc --dry-run, tests all clean.