hirosystems / clarinet

Write, test and deploy high-quality smart contracts to the Stacks blockchain and Bitcoin.
https://hiro.so/clarinet
GNU General Public License v3.0
290 stars 129 forks source link

fix: add a safety check in lsp check_if_should_wrap #1459

Closed hugocaillard closed 1 month ago

hugocaillard commented 1 month ago

Description

In some rare cases, eg: if the LSP state isn't up to date, it's possible that the cursor position is past the end of the line (as the LSP sees it).

This PR adds a safety check before getting the beginning of the line with line[..position.character as usize]. This PR also slightly refactor this method

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 40.72%. Comparing base (fdb3b3f) to head (43085cc).

Files Patch % Lines
...ents/clarity-lsp/src/common/requests/completion.rs 0.00% 7 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1459 +/- ## ========================================== + Coverage 40.71% 40.72% +0.01% ========================================== Files 87 87 Lines 32405 32404 -1 ========================================== + Hits 13193 13197 +4 + Misses 19212 19207 -5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.