-
Notifications
You must be signed in to change notification settings - Fork 996
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
Add support for highlighting enclosing brackets #2622
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2622 +/- ##
==========================================
- Coverage 11.65% 11.64% -0.01%
==========================================
Files 141 141
Lines 43634 44103 +469
==========================================
+ Hits 5084 5135 +51
- Misses 38550 38968 +418
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
lapce-app/src/editor/view.rs
Outdated
// We only need to draw anything if start_line is on or before the visible section and | ||
// end_line is on or after the visible section. | ||
let y0 = start_line_y.or_else(|| { | ||
(start_line < *screen_lines.lines.first().unwrap()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it valid to assume that screen_lines.lines
is non-empty and sorted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's sorted but could be empty I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to not assume that screen_lines.lines
is non-empty.
let end = self.find_matching_pair(start)?; | ||
if end >= offset { | ||
return Some((start, end)); | ||
if start < offset { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously the the offset immediately before an opening bracket was considered enclosed (i.e.: |( )
). This was inconsistent with WordCursor::find_enclosing_pair
, which is used for language unaware bracket search, so I've changed it to not consider that offset to be enclosed.
@@ -428,7 +428,7 @@ impl<'a> WordCursor<'a> { | |||
if matching_pair_direction(c) == Some(true) { | |||
let opening_bracket_offset = self.inner.pos(); | |||
if let Some(closing_bracket_offset) = self.match_pairs() { | |||
if (opening_bracket_offset..closing_bracket_offset) | |||
if (opening_bracket_offset..=closing_bracket_offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a bug where the offset immediately before the closing bracket (i.e.: ( |)
) was not considered enclosed.
Highlight enclosing brackets when `highlight_matching_brackets` is enabled. Draw lines delineating the enclosing scope when `highlight_scope_lines` is enabled.
67c0921
to
715ebd6
Compare
Highlight enclosing brackets when
highlight_matching_brackets
is enabled.Draw lines delineating the enclosing scope when
highlight_scope_lines
is enabled.Currently only draws the highlights and scope lines for one cursor, even if there are multiple cursors.
Currently doesn't draw highlights or scope lines on the sticky header.
Relates to #2417.
CHANGELOG.md
if this change could be valuable to users