@@ -237,6 +237,7 @@ impl Command {
237237 goto_window_bottom, "Goto window bottom",
238238 goto_last_accessed_file, "Goto last accessed file",
239239 goto_line, "Goto line",
240+ goto_last_line, "Goto last line",
240241 goto_first_diag, "Goto first diagnostic",
241242 goto_last_diag, "Goto last diagnostic",
242243 goto_next_diag, "Goto next diagnostic",
@@ -2426,12 +2427,32 @@ fn goto_line(cx: &mut Context) {
24262427 push_jump(cx.editor);
24272428
24282429 let (view, doc) = current!(cx.editor);
2429− let line_idx = std::cmp::min(count.get() - 1, doc.text().len_lines().saturating_sub(2));
2430+ let max_line = if doc.text().line(doc.text().len_lines() - 1).len_chars() == 0 {
2431+ // If the last line is blank, don't jump to it.
2432+ doc.text().len_lines().saturating_sub(2)
2433+ } else {
2434+ doc.text().len_lines() - 1
2435+ };
2436+ let line_idx = std::cmp::min(count.get() - 1, max_line);
24302437 let pos = doc.text().line_to_char(line_idx);
24312438 doc.set_selection(view.id, Selection::point(pos));
24322439 }
24332440}
24342441
2442+fn goto_last_line(cx: &mut Context) {
2443+ push_jump(cx.editor);
2444+
2445+ let (view, doc) = current!(cx.editor);
2446+ let line_idx = if doc.text().line(doc.text().len_lines() - 1).len_chars() == 0 {
2447+ // If the last line is blank, don't jump to it.
2448+ doc.text().len_lines().saturating_sub(2)
2449+ } else {
2450+ doc.text().len_lines() - 1
2451+ };
2452+ let pos = doc.text().line_to_char(line_idx);
2453+ doc.set_selection(view.id, Selection::point(pos));
2454+}
2455+
24352456fn goto_last_accessed_file(cx: &mut Context) {
24362457 let alternate_file = view!(cx.editor).last_accessed_doc;
24372458 if let Some(alt) = alternate_file {