Repository navigation
Fix caret positioning when CLI truncates long source lines - #3292
Open
Mihir-Rabari wants to merge 2 commits into
Open
Mihir-Rabari wants to merge 2 commits into
Mihir-Rabari wants to merge 2 commits into
Conversation
Comment on lines
+1
to
+5
| { | ||
| "type": "bugfix", | ||
| "description": "Fix CLI output when rendering long source lines so that the pointer never goes past the truncation marker. Fixes [#2491](https://github.com/smithy-lang/smithy/issues/2491)", | ||
| "pull_requests": [] | ||
| } |
Contributor
There was a problem hiding this comment.
Staged changelog entries should have an associated pull request set. Commit this suggestion to associate this changelog entry with this PR.
Suggested change
| { | |
| "type": "bugfix", | |
| "description": "Fix CLI output when rendering long source lines so that the pointer never goes past the truncation marker. Fixes [#2491](https://github.com/smithy-lang/smithy/issues/2491)", | |
| "pull_requests": [] | |
| } | |
| { | |
| "type": "bugfix", | |
| "description": "Fix CLI output when rendering long source lines so that the pointer never goes past the truncation marker. Fixes [#2491](https://github.com/smithy-lang/smithy/issues/2491)", | |
| "pull_requests": [ | |
| "[#3292](https://github.com/smithy-lang/smithy/pull/3292)" | |
| ] | |
| } |
This branch has not been deployed
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.
Background
smithy validatetruncates long source lines when rendering validation events, but the pointer (caret) was positioned using the raw column of the untruncated line — so on long lines (e.g. wide minified JSON) it rendered far past the…truncation marker, as reported in #2491. While fixing this, I found a second, latent issue: the marker was appended with alength >= allowedSizecondition, so lines that exactly fit the available width also got a spurious….Testing
CodeFormatterTestcases pinning the behavior: an exactly-fitting line renders fully with the correct caret and no marker; a long line is truncated with the caret inside the visible window under the right character; an error column far past the window clamps the caret exactly onto the…marker (never past it — the acceptance criterion from the issue); carets at column 1 and at the last visible column both position correctly../gradlew :smithy-cli:build(tests + spotless + spotbugs + javadoc) — BUILD SUCCESSFUL, all 18 tests inCodeFormatterTestandPrettyAnsiValidationFormatterTestgreen.Links
Fixes #2491
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.