Skip to content

Commit

Permalink
feedback: address clippy complaints, and extract variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
alevinval committed Oct 15, 2022
1 parent 7bbce6a commit 538f3f8
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4083,21 +4083,19 @@ fn match_brackets(cx: &mut Context) {
let (view, doc) = current!(cx.editor);

if let Some(syntax) = doc.syntax() {
let text = doc.text().slice(..);
let text = doc.text();
let text_slice = text.slice(..);
let is_select = cx.editor.mode == Mode::Select;
let selection = doc.selection(view.id).clone().transform(|range| {
if let Some(pos) =
match_brackets::find_matching_bracket_fuzzy(syntax, doc.text(), range.cursor(text))
let pos = range.cursor(text_slice);
if let Some(pos) = match_brackets::find_matching_bracket_fuzzy(syntax, text, pos) {
range.put_cursor(text_slice, pos, is_select)
} else if let Some(pos) =
match_brackets::find_matching_bracket_current_line_plaintext(text, pos)
{
range.put_cursor(text, pos, cx.editor.mode == Mode::Select)
range.put_cursor(text_slice, pos, is_select)
} else {
if let Some(pos) = match_brackets::find_matching_bracket_current_line_plaintext(
doc.text(),
range.cursor(text),
) {
range.put_cursor(text, pos, cx.editor.mode == Mode::Select)
} else {
range
}
range
}
});
doc.set_selection(view.id, selection);
Expand Down

0 comments on commit 538f3f8

Please sign in to comment.