on master help sign in
jumplist: Add documents to view history (#3593)
701cea5Michael Davis
helix-term/src/commands.rs+12−2
@@ -4060,13 +4060,18 @@ fn match_brackets(cx: &mut Context) {
4060fn jump_forward(cx: &mut Context) {
4060fn jump_forward(cx: &mut Context) {
4061 let count = cx.count();
4061 let count = cx.count();
4062 let view = view_mut!(cx.editor);
4062 let view = view_mut!(cx.editor);
4063+ let doc_id = view.doc;
4063
4064
4064 if let Some((id, selection)) = view.jumps.forward(count) {
4065 if let Some((id, selection)) = view.jumps.forward(count) {
4065 view.doc = *id;
4066 view.doc = *id;
4066 let selection = selection.clone();
4067 let selection = selection.clone();
4067 let (view, doc) = current!(cx.editor); // refetch doc
4068 let (view, doc) = current!(cx.editor); // refetch doc
4068− doc.set_selection(view.id, selection);
4069
4069
4070+ if doc.id() != doc_id {
4071+ view.add_to_history(doc_id);
4072+ }
4073+
4074+ doc.set_selection(view.id, selection);
4070 align_view(doc, view, Align::Center);
4075 align_view(doc, view, Align::Center);
4071 };
4076 };
4072}
4077}
@@ -4074,13 +4079,18 @@ fn jump_forward(cx: &mut Context) {
4074fn jump_backward(cx: &mut Context) {
4079fn jump_backward(cx: &mut Context) {
4075 let count = cx.count();
4080 let count = cx.count();
4076 let (view, doc) = current!(cx.editor);
4081 let (view, doc) = current!(cx.editor);
4082+ let doc_id = doc.id();
4077
4083
4078 if let Some((id, selection)) = view.jumps.backward(view.id, doc, count) {
4084 if let Some((id, selection)) = view.jumps.backward(view.id, doc, count) {
4079 view.doc = *id;
4085 view.doc = *id;
4080 let selection = selection.clone();
4086 let selection = selection.clone();
4081 let (view, doc) = current!(cx.editor); // refetch doc
4087 let (view, doc) = current!(cx.editor); // refetch doc
4082− doc.set_selection(view.id, selection);
4083
4088
4089+ if doc.id() != doc_id {
4090+ view.add_to_history(doc_id);
4091+ }
4092+
4093+ doc.set_selection(view.id, selection);
4084 align_view(doc, view, Align::Center);
4094 align_view(doc, view, Align::Center);
4085 };
4095 };
4086}
4096}