Skip to content
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

feat: make more commands exit select mode #8689

Merged
merged 6 commits into from
Nov 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ fn align_selections(cx: &mut Context) {

let transaction = Transaction::change(doc.text(), changes.into_iter());
doc.apply(&transaction, view.id);
exit_select_mode(cx);
}

fn goto_window(cx: &mut Context, align: Align) {
Expand Down Expand Up @@ -1527,6 +1528,7 @@ where
});

doc.apply(&transaction, view.id);
exit_select_mode(cx);
}

fn switch_case(cx: &mut Context) {
Expand Down Expand Up @@ -4085,22 +4087,27 @@ pub(crate) fn paste_bracketed_value(cx: &mut Context, contents: String) {
};
let (view, doc) = current!(cx.editor);
paste_impl(&[contents], doc, view, paste, count, cx.editor.mode);
exit_select_mode(cx);
}

fn paste_clipboard_after(cx: &mut Context) {
paste(cx.editor, '+', Paste::After, cx.count());
exit_select_mode(cx);
}

fn paste_clipboard_before(cx: &mut Context) {
paste(cx.editor, '+', Paste::Before, cx.count());
exit_select_mode(cx);
}

fn paste_primary_clipboard_after(cx: &mut Context) {
paste(cx.editor, '*', Paste::After, cx.count());
exit_select_mode(cx);
}

fn paste_primary_clipboard_before(cx: &mut Context) {
paste(cx.editor, '*', Paste::Before, cx.count());
exit_select_mode(cx);
}

fn replace_with_yanked(cx: &mut Context) {
Expand Down Expand Up @@ -4139,10 +4146,12 @@ fn replace_with_yanked_impl(editor: &mut Editor, register: char, count: usize) {

fn replace_selections_with_clipboard(cx: &mut Context) {
replace_with_yanked_impl(cx.editor, '+', cx.count());
exit_select_mode(cx);
}

fn replace_selections_with_primary_clipboard(cx: &mut Context) {
replace_with_yanked_impl(cx.editor, '*', cx.count());
exit_select_mode(cx);
}

fn paste(editor: &mut Editor, register: char, pos: Paste, count: usize) {
Expand All @@ -4160,6 +4169,7 @@ fn paste_after(cx: &mut Context) {
Paste::After,
cx.count(),
);
exit_select_mode(cx);
}

fn paste_before(cx: &mut Context) {
Expand All @@ -4169,6 +4179,7 @@ fn paste_before(cx: &mut Context) {
Paste::Before,
cx.count(),
);
exit_select_mode(cx);
}

fn get_lines(doc: &Document, view_id: ViewId) -> Vec<usize> {
Expand Down Expand Up @@ -4207,6 +4218,7 @@ fn indent(cx: &mut Context) {
}),
);
doc.apply(&transaction, view.id);
exit_select_mode(cx);
}

fn unindent(cx: &mut Context) {
Expand Down Expand Up @@ -4246,6 +4258,7 @@ fn unindent(cx: &mut Context) {
let transaction = Transaction::change(doc.text(), changes.into_iter());

doc.apply(&transaction, view.id);
exit_select_mode(cx);
}

fn format_selections(cx: &mut Context) {
Expand Down Expand Up @@ -5671,6 +5684,7 @@ fn increment_impl(cx: &mut Context, increment_direction: IncrementDirection) {
let transaction = Transaction::change(doc.text(), changes.into_iter());
let transaction = transaction.with_selection(new_selection);
doc.apply(&transaction, view.id);
exit_select_mode(cx);
}
}

Expand Down
Loading