Avoid modifying jumplist until jumping to ref (#2670)

When a goto command is cancelled, the jumplist should remain unchanged.

This commit delays saving the current selection to the jumplist until
jumping to a reference.
pull/2681/head
yzwduck 3 years ago committed by GitHub
parent 026241cf72
commit d24ca66dbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -485,8 +485,6 @@ fn goto_impl(
locations: Vec<lsp::Location>, locations: Vec<lsp::Location>,
offset_encoding: OffsetEncoding, offset_encoding: OffsetEncoding,
) { ) {
push_jump(editor);
let cwdir = std::env::current_dir().expect("couldn't determine current directory"); let cwdir = std::env::current_dir().expect("couldn't determine current directory");
match locations.as_slice() { match locations.as_slice() {
@ -520,6 +518,7 @@ fn goto_impl(
format!("{}:{}", file, line).into() format!("{}:{}", file, line).into()
}, },
move |cx, location, action| { move |cx, location, action| {
push_jump(cx.editor);
jump_to_location(cx.editor, location, offset_encoding, action) jump_to_location(cx.editor, location, offset_encoding, action)
}, },
move |_editor, location| Some(location_to_file_location(location)), move |_editor, location| Some(location_to_file_location(location)),

Loading…
Cancel
Save