Skip to content

Commit

Permalink
Add new command to cycle through version control conflict markers
Browse files Browse the repository at this point in the history
  • Loading branch information
wes adams committed Nov 11, 2022
1 parent d7be546 commit 4d67be9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
19 changes: 19 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ impl MappableCommand {
goto_prev_test, "Goto previous test",
goto_next_paragraph, "Goto next paragraph",
goto_prev_paragraph, "Goto previous paragraph",
goto_next_conflict_marker, "Goto next conflict marker",
goto_prev_conflict_marker, "Goto prev conflict marker",
dap_launch, "Launch debug target",
dap_toggle_breakpoint, "Toggle breakpoint",
dap_continue, "Continue program execution",
Expand Down Expand Up @@ -984,6 +986,23 @@ fn goto_next_paragraph(cx: &mut Context) {
goto_para_impl(cx, movement::move_next_paragraph)
}

fn goto_conflict_marker(cx: &mut Context, movement: Movement, direction: Direction) {
let (_, doc) = current!(cx.editor);
let contents = doc.text().slice(..).to_string();
let re = Regex::new("<<<<<<<|=======|>>>>>>>").unwrap();
search_impl(
cx.editor, &contents, &re, movement, direction, 0, true, true,
);
}

fn goto_next_conflict_marker(cx: &mut Context) {
goto_conflict_marker(cx, Movement::Move, Direction::Forward)
}

fn goto_prev_conflict_marker(cx: &mut Context) {
goto_conflict_marker(cx, Movement::Move, Direction::Backward)
}

fn goto_file_start(cx: &mut Context) {
if cx.count.is_some() {
goto_line(cx);
Expand Down
2 changes: 2 additions & 0 deletions helix-term/src/keymap/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
"o" => goto_prev_comment,
"t" => goto_prev_test,
"p" => goto_prev_paragraph,
"n" => goto_prev_conflict_marker,
"space" => add_newline_above,
},
"]" => { "Right bracket"
Expand All @@ -117,6 +118,7 @@ pub fn default() -> HashMap<Mode, Keymap> {
"o" => goto_next_comment,
"t" => goto_next_test,
"p" => goto_next_paragraph,
"n" => goto_next_conflict_marker,
"space" => add_newline_below,
},

Expand Down

0 comments on commit 4d67be9

Please sign in to comment.