This commit is contained in:
Nathan Sobo 2023-11-02 22:56:04 -06:00
parent a731f8fb1e
commit f3b8a9d8c2
26 changed files with 1782 additions and 1665 deletions

View file

@ -5,29 +5,30 @@ use crate::{Editor, RangeToAnchorExt};
enum MatchingBracketHighlight {}
pub fn refresh_matching_bracket_highlights(editor: &mut Editor, cx: &mut ViewContext<Editor>) {
editor.clear_background_highlights::<MatchingBracketHighlight>(cx);
todo!()
// // editor.clear_background_highlights::<MatchingBracketHighlight>(cx);
let newest_selection = editor.selections.newest::<usize>(cx);
// Don't highlight brackets if the selection isn't empty
if !newest_selection.is_empty() {
return;
}
// let newest_selection = editor.selections.newest::<usize>(cx);
// // Don't highlight brackets if the selection isn't empty
// if !newest_selection.is_empty() {
// return;
// }
let head = newest_selection.head();
let snapshot = editor.snapshot(cx);
if let Some((opening_range, closing_range)) = snapshot
.buffer_snapshot
.innermost_enclosing_bracket_ranges(head..head)
{
editor.highlight_background::<MatchingBracketHighlight>(
vec![
opening_range.to_anchors(&snapshot.buffer_snapshot),
closing_range.to_anchors(&snapshot.buffer_snapshot),
],
|theme| theme.editor.document_highlight_read_background,
cx,
)
}
// let head = newest_selection.head();
// let snapshot = editor.snapshot(cx);
// if let Some((opening_range, closing_range)) = snapshot
// .buffer_snapshot
// .innermost_enclosing_bracket_ranges(head..head)
// {
// editor.highlight_background::<MatchingBracketHighlight>(
// vec![
// opening_range.to_anchors(&snapshot.buffer_snapshot),
// closing_range.to_anchors(&snapshot.buffer_snapshot),
// ],
// |theme| theme.editor.document_highlight_read_background,
// cx,
// )
// }
}
// #[cfg(test)]