|
|
@ -2053,15 +2053,9 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) {
|
|
|
|
let selection = doc.selection(view.id).clone().transform(|range| {
|
|
|
|
let selection = doc.selection(view.id).clone().transform(|range| {
|
|
|
|
let (start_line, end_line) = range.line_range(text.slice(..));
|
|
|
|
let (start_line, end_line) = range.line_range(text.slice(..));
|
|
|
|
|
|
|
|
|
|
|
|
let start = text.line_to_char(match extend {
|
|
|
|
let start = text.line_to_char(start_line);
|
|
|
|
Extend::Above => start_line.saturating_sub(count - 1),
|
|
|
|
|
|
|
|
Extend::Below => start_line,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
let end = text.line_to_char(
|
|
|
|
let end = text.line_to_char(
|
|
|
|
match extend {
|
|
|
|
(end_line + 1) // newline of end_line
|
|
|
|
Extend::Above => end_line + 1, // the start of next line
|
|
|
|
|
|
|
|
Extend::Below => end_line + count,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.min(text.len_lines()),
|
|
|
|
.min(text.len_lines()),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -2076,8 +2070,11 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
match extend {
|
|
|
|
match extend {
|
|
|
|
Extend::Above => (end, start),
|
|
|
|
Extend::Above => (end, text.line_to_char(start_line.saturating_sub(count - 1))),
|
|
|
|
Extend::Below => (start, end),
|
|
|
|
Extend::Below => (
|
|
|
|
|
|
|
|
start,
|
|
|
|
|
|
|
|
text.line_to_char((end_line + count).min(text.len_lines())),
|
|
|
|
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|