@@ -1545,7 +1545,7 @@ fn searcher(cx: &mut Context, direction: Direction) {
1545 let reg = cx.register.unwrap_or('/');
1545 let reg = cx.register.unwrap_or('/');
1546 let scrolloff = cx.editor.config.scrolloff;
1546 let scrolloff = cx.editor.config.scrolloff;
1548− let (_, doc) = current!(cx.editor);
1548+ let doc = doc!(cx.editor);
1550 // TODO: could probably share with select_on_matches?
1550 // TODO: could probably share with select_on_matches?
@@ -2046,7 +2046,7 @@ pub mod cmd {
2047 fn write_impl(cx: &mut compositor::Context, path: Option<&Cow<str>>) -> anyhow::Result<()> {
2047 fn write_impl(cx: &mut compositor::Context, path: Option<&Cow<str>>) -> anyhow::Result<()> {
2048 let jobs = &mut cx.jobs;
2048 let jobs = &mut cx.jobs;
2049− let (_, doc) = current!(cx.editor);
2049+ let doc = doc_mut!(cx.editor);
2051 if let Some(ref path) = path {
2051 if let Some(ref path) = path {
2052 doc.set_path(Some(path.as_ref().as_ref()))
2052 doc.set_path(Some(path.as_ref().as_ref()))
@@ -2099,8 +2099,7 @@ pub mod cmd {
2099 _args: &[Cow<str>],
2099 _args: &[Cow<str>],
2100 _event: PromptEvent,
2100 _event: PromptEvent,
2101 ) -> anyhow::Result<()> {
2101 ) -> anyhow::Result<()> {
2102− let (_, doc) = current!(cx.editor);
2102+ let doc = doc!(cx.editor);
2104 if let Some(format) = doc.format() {
2103 if let Some(format) = doc.format() {
2105 let callback =
2104 let callback =
2106 make_format_callback(doc.id(), doc.version(), Modified::LeaveModified, format);
2105 make_format_callback(doc.id(), doc.version(), Modified::LeaveModified, format);
@@ -2409,7 +2408,7 @@ pub mod cmd {
2409 args: &[Cow<str>],
2408 args: &[Cow<str>],
2410 _event: PromptEvent,
2409 _event: PromptEvent,
2411 ) -> anyhow::Result<()> {
2410 ) -> anyhow::Result<()> {
2412− let (_, doc) = current!(cx.editor);
2411+ let doc = doc!(cx.editor);
2413 let default_sep = Cow::Borrowed(doc.line_ending.as_str());
2412 let default_sep = Cow::Borrowed(doc.line_ending.as_str());
2414 let separator = args.first().unwrap_or(&default_sep);
2413 let separator = args.first().unwrap_or(&default_sep);
2415 yank_joined_to_clipboard_impl(cx.editor, separator, ClipboardType::Clipboard)
2414 yank_joined_to_clipboard_impl(cx.editor, separator, ClipboardType::Clipboard)
@@ -2428,7 +2427,7 @@ pub mod cmd {
2428 args: &[Cow<str>],
2427 args: &[Cow<str>],
2429 _event: PromptEvent,
2428 _event: PromptEvent,
2430 ) -> anyhow::Result<()> {
2429 ) -> anyhow::Result<()> {
2431− let (_, doc) = current!(cx.editor);
2430+ let doc = doc!(cx.editor);
2432 let default_sep = Cow::Borrowed(doc.line_ending.as_str());
2431 let default_sep = Cow::Borrowed(doc.line_ending.as_str());
2433 let separator = args.first().unwrap_or(&default_sep);
2432 let separator = args.first().unwrap_or(&default_sep);
2434 yank_joined_to_clipboard_impl(cx.editor, separator, ClipboardType::Selection)
2433 yank_joined_to_clipboard_impl(cx.editor, separator, ClipboardType::Selection)
@@ -2555,7 +2554,7 @@ pub mod cmd {
2555 args: &[Cow<str>],
2554 args: &[Cow<str>],
2556 _event: PromptEvent,
2555 _event: PromptEvent,
2557 ) -> anyhow::Result<()> {
2556 ) -> anyhow::Result<()> {
2558− let (_, doc) = current!(cx.editor);
2557+ let doc = doc_mut!(cx.editor);
2559 if let Some(label) = args.first() {
2558 if let Some(label) = args.first() {
2560 doc.set_encoding(label)
2559 doc.set_encoding(label)
2561 } else {
2560 } else {
@@ -3247,7 +3246,7 @@ fn symbol_picker(cx: &mut Context) {
3247 nested_to_flat(list, file, child);
3246 nested_to_flat(list, file, child);
3250− let (_, doc) = current!(cx.editor);
3249+ let doc = doc!(cx.editor);
3252 let language_server = match doc.language_server() {
3251 let language_server = match doc.language_server() {
3253 Some(language_server) => language_server,
3252 Some(language_server) => language_server,
@@ -3268,7 +3267,7 @@ fn symbol_picker(cx: &mut Context) {
3268 let symbols = match symbols {
3267 let symbols = match symbols {
3269 lsp::DocumentSymbolResponse::Flat(symbols) => symbols,
3268 lsp::DocumentSymbolResponse::Flat(symbols) => symbols,
3270 lsp::DocumentSymbolResponse::Nested(symbols) => {
3269 lsp::DocumentSymbolResponse::Nested(symbols) => {
3271− let (_view, doc) = current!(editor);
3270+ let doc = doc!(editor);
3272 let mut flat_symbols = Vec::new();
3271 let mut flat_symbols = Vec::new();
3273 for symbol in symbols {
3272 for symbol in symbols {
3274 nested_to_flat(&mut flat_symbols, &doc.identifier(), symbol)
3273 nested_to_flat(&mut flat_symbols, &doc.identifier(), symbol)
@@ -3310,17 +3309,15 @@ fn symbol_picker(cx: &mut Context) {
3312fn workspace_symbol_picker(cx: &mut Context) {
3311fn workspace_symbol_picker(cx: &mut Context) {
3313− let (_, doc) = current!(cx.editor);
3312+ let doc = doc!(cx.editor);
3314−
3313+ let current_path = doc.path().cloned();
3315 let language_server = match doc.language_server() {
3314 let language_server = match doc.language_server() {
3316 Some(language_server) => language_server,
3315 Some(language_server) => language_server,
3317 None => return,
3316 None => return,
3319 let offset_encoding = language_server.offset_encoding();
3318 let offset_encoding = language_server.offset_encoding();
3321 let future = language_server.workspace_symbols("".to_string());
3319 let future = language_server.workspace_symbols("".to_string());
3323− let current_path = doc_mut!(cx.editor).path().cloned();
3324 cx.callback(
3321 cx.callback(
3326 move |_editor: &mut Editor,
3323 move |_editor: &mut Editor,
@@ -3430,8 +3427,7 @@ pub fn code_action(cx: &mut Context) {
3432pub fn execute_lsp_command(editor: &mut Editor, cmd: lsp::Command) {
3429pub fn execute_lsp_command(editor: &mut Editor, cmd: lsp::Command) {
3433− let (_view, doc) = current!(editor);
3430+ let doc = doc!(editor);
3435 let language_server = match doc.language_server() {
3431 let language_server = match doc.language_server() {
3436 Some(language_server) => language_server,
3432 Some(language_server) => language_server,
3437 None => return,
3433 None => return,
@@ -4185,27 +4181,21 @@ fn goto_pos(editor: &mut Editor, pos: usize) {
4187fn goto_first_diag(cx: &mut Context) {
4183fn goto_first_diag(cx: &mut Context) {
4188− let editor = &mut cx.editor;
4184+ let doc = doc!(cx.editor);
4189− let (_, doc) = current!(editor);
4191 let pos = match doc.diagnostics().first() {
4185 let pos = match doc.diagnostics().first() {
4192 Some(diag) => diag.range.start,
4186 Some(diag) => diag.range.start,
4193 None => return,
4187 None => return,
4196− goto_pos(editor, pos);
4189+ goto_pos(cx.editor, pos);
4199fn goto_last_diag(cx: &mut Context) {
4192fn goto_last_diag(cx: &mut Context) {
4200− let editor = &mut cx.editor;
4193+ let doc = doc!(cx.editor);
4201− let (_, doc) = current!(editor);
4203 let pos = match doc.diagnostics().last() {
4194 let pos = match doc.diagnostics().last() {
4204 Some(diag) => diag.range.start,
4195 Some(diag) => diag.range.start,
4205 None => return,
4196 None => return,
4208− goto_pos(editor, pos);
4198+ goto_pos(cx.editor, pos);
4211fn goto_next_diag(cx: &mut Context) {
4201fn goto_next_diag(cx: &mut Context) {
@@ -5270,7 +5260,7 @@ pub fn completion(cx: &mut Context) {
5270 move |editor: &mut Editor,
5260 move |editor: &mut Editor,
5271 compositor: &mut Compositor,
5261 compositor: &mut Compositor,
5272 response: Option<lsp::CompletionResponse>| {
5262 response: Option<lsp::CompletionResponse>| {
5273− let (_, doc) = current!(editor);
5263+ let doc = doc!(editor);
5274 if doc.mode() != Mode::Insert {
5264 if doc.mode() != Mode::Insert {
5275 // we're not in insert mode anymore
5265 // we're not in insert mode anymore