Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: misplaced shellcheck spans #317

Merged

Conversation

thatRichman
Copy link
Contributor

@thatRichman thatRichman commented Jan 26, 2025

Describe the problem or feature in addition to a link to the issues.

This PR addresses the bug described in #307, wherein shellcheck highlight spans were sometimes misplaced. This was due to incorrect counting of the amount of leading whitespace stripped by CommandSection::strip_whitespace. To avoid duplicating logic from the aforementioned method, the whitespace counting portion was refactored into a separate method, count_whitespace so that both strip_whitespace and sanitize_command can make use of it.

Before submitting this PR, please make sure:

  • You have added a few sentences describing the PR here.
  • You have added yourself or the appropriate individual as the assignee.
  • You have added at least one relevant code reviewer to the PR.
  • Your code builds clean without any errors or warnings.
  • You have added tests (when appropriate).
  • You have updated the README or other documentation to account for these
    changes (when appropriate).
  • You have added an entry to the relevant CHANGELOG.md (see
    ["keep a changelog"] for more information).
  • Your commit messages follow the [conventional commit] style.

@@ -439,8 +441,7 @@ fn calculate_span(diagnostic: &ShellCheckDiagnostic, line_map: &HashMap<usize, S
.start()
+ diagnostic.end_column
- 1;
// - 2 to discount first and last newlines
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This -2 was mis-attributed to newlines and was actually a coincidental artifact of the number of line continuations in my test cases. Doh.

Copy link
Member

@a-frantz a-frantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for this!

Copy link
Collaborator

@peterhuene peterhuene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for fixing this!

@peterhuene peterhuene merged commit b470f0b into stjude-rust-labs:main Jan 27, 2025
16 checks passed
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.

3 participants