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

Fix ctrl-u on insert behavior #1957

Merged
merged 2 commits into from
Apr 23, 2022
Merged
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,20 @@ fn kill_to_line_start(cx: &mut Context) {

let selection = doc.selection(view.id).clone().transform(|range| {
let line = range.cursor_line(text);
range.put_cursor(text, text.line_to_char(line), true)
let first_char = text.line_to_char(line);
let anchor = range.cursor(text);
let head = if anchor == first_char && line != 0 {
line_end_char_index(&text, line - 1)
} else if let Some(pos) = find_first_non_whitespace_char(text.line(line)) {
if first_char + pos < anchor {
first_char + pos
} else {
first_char
}
} else {
first_char
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole block has no comments and is kind of hard for me to understand what it's doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I thought it was clear enough, added comments now.

Range::new(head, anchor)
});
delete_selection_insert_mode(doc, view, &selection);
}
Expand Down