Skip to content

Commit

Permalink
renaming and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Tudyx committed Jul 11, 2023
1 parent 0a7b0a8 commit 8ad0403
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2315,14 +2315,14 @@ enum Operation {
Change,
}

fn only_whole_lines(selection: &Selection, text: &Rope) -> bool {
fn selection_is_linewise(selection: &Selection, text: &Rope) -> bool {
selection.ranges().iter().all(|range| {
// If not at least a full line is selected (strange require 2).
if range.slice(text.slice(..)).len_lines() < 2 {
let text = text.slice(..);
if range.slice(text).len_lines() < 2 {
return false;
}
// If the start of the selection is at the start of a line and the end at the end of a line.
let (start_line, end_line) = range.line_range(text.slice(..));
let (start_line, end_line) = range.line_range(text);
let start = text.line_to_char(start_line);
let end = text.line_to_char((end_line + 1).min(text.len_lines()));
start == range.from() && end == range.to()
Expand All @@ -2333,7 +2333,7 @@ fn delete_selection_impl(cx: &mut Context, op: Operation) {
let (view, doc) = current!(cx.editor);

let selection = doc.selection(view.id);
let only_whole_lines = only_whole_lines(selection, doc.text());
let only_whole_lines = selection_is_linewise(selection, doc.text());

if cx.register != Some('_') {
// first yank the selection
Expand Down

0 comments on commit 8ad0403

Please sign in to comment.