@@ -1317,6 +1317,15 @@ fn push_jump(editor: &mut Editor) {
13171317 view.jumps.push(jump);
13181318}
13191319
1320+fn switch_to_last_accessed_file(cx: &mut Context) {
1321+ let alternate_file = cx.view().last_accessed_doc;
1322+ if let Some(alt) = alternate_file {
1323+ cx.editor.switch(alt, Action::Replace);
1324+ } else {
1325+ cx.editor.set_error("no last buffer".to_owned())
1326+ }
1327+}
1328+
13201329pub fn goto_mode(cx: &mut Context) {
13211330 if let Some(count) = cx._count {
13221331 push_jump(cx.editor);
@@ -1338,6 +1347,7 @@ pub fn goto_mode(cx: &mut Context) {
13381347 match (cx.doc().mode, ch) {
13391348 (_, 'g') => move_file_start(cx),
13401349 (_, 'e') => move_file_end(cx),
1350+ (_, 'a') => switch_to_last_accessed_file(cx),
13411351 (Mode::Normal, 'h') => move_line_start(cx),
13421352 (Mode::Normal, 'l') => move_line_end(cx),
13431353 (Mode::Select, 'h') => extend_line_start(cx),
@@ -2449,6 +2459,10 @@ pub fn jump_backward(cx: &mut Context) {
24492459 let (view, doc) = cx.current();
24502460
24512461 if let Some((id, selection)) = view.jumps.backward(view.id, doc, count) {
2462+ // manually set the alternate_file as we cannot use the Editor::switch function here.
2463+ if view.doc != *id {
2464+ view.last_accessed_doc = Some(view.doc)
2465+ }
24522466 view.doc = *id;
24532467 let selection = selection.clone();
24542468 let (view, doc) = cx.current(); // refetch doc