@@ -247,6 +247,7 @@ impl MappableCommand {
247 search_selection, "Use current selection as search pattern",
247 search_selection, "Use current selection as search pattern",
248 global_search, "Global Search in workspace folder",
248 global_search, "Global Search in workspace folder",
249 extend_line, "Select current line, if already selected, extend to next line",
249 extend_line, "Select current line, if already selected, extend to next line",
250+ extend_line_above, "Select current line, if already selected, extend to previous line",
250 extend_to_line_bounds, "Extend selection to line bounds (line-wise selection)",
251 extend_to_line_bounds, "Extend selection to line bounds (line-wise selection)",
251 delete_selection, "Delete selection",
252 delete_selection, "Delete selection",
252 delete_selection_noyank, "Delete selection, without yanking",
253 delete_selection_noyank, "Delete selection, without yanking",
@@ -1854,7 +1855,20 @@ fn global_search(cx: &mut Context) {
1854 cx.jobs.callback(show_picker);
1855 cx.jobs.callback(show_picker);
1857fn extend_line(cx: &mut Context) {
1863fn extend_line(cx: &mut Context) {
1864+ extend_line_impl(cx, Extend::Below);
1867+fn extend_line_above(cx: &mut Context) {
1868+ extend_line_impl(cx, Extend::Above);
1871+fn extend_line_impl(cx: &mut Context, extend: Extend) {
1858 let count = cx.count();
1872 let count = cx.count();
1859 let (view, doc) = current!(cx.editor);
1873 let (view, doc) = current!(cx.editor);
@@ -1863,13 +1877,22 @@ fn extend_line(cx: &mut Context) {
1863 let (start_line, end_line) = range.line_range(text.slice(..));
1877 let (start_line, end_line) = range.line_range(text.slice(..));
1865 let start = text.line_to_char(start_line);
1879 let start = text.line_to_char(start_line);
1866− let mut end = text.line_to_char((end_line + count).min(text.len_lines()));
1880+ let end = text.line_to_char((end_line + count).min(text.len_lines()));
1882+ // extend to previous/next line if current line is selected
1883+ let (anchor, head) = if range.from() == start && range.to() == end {
1885+ Extend::Above => (end, text.line_to_char(start_line.saturating_sub(1))),
1888+ text.line_to_char((end_line + count + 1).min(text.len_lines())),
1868− // go to next line if current line is selected
1869− if range.from() == start && range.to() == end {
1870− end = text.line_to_char((end_line + count + 1).min(text.len_lines()));
1872− Range::new(start, end)
1895+ Range::new(anchor, head)
1875 doc.set_selection(view.id, selection);
1898 doc.set_selection(view.id, selection);