@@ -1250,7 +1250,8 @@ pub fn goto_mode(cx: &mut Context) {
12501250 // TODO: can't go to line 1 since we can't distinguish between g and 1g, g gets converted
12511251 // to 1g
12521252 let (view, doc) = cx.current();
1253− let pos = doc.text().line_to_char(count - 1);
1253+ let line_idx = std::cmp::min(count - 1, doc.text().len_lines().saturating_sub(2));
1254+ let pos = doc.text().line_to_char(line_idx);
12541255 doc.set_selection(view.id, Selection::point(pos));
12551256 return;
12561257 }