diff --git a/crates/vim/src/normal.rs b/crates/vim/src/normal.rs index 475e9e73d3..1d70227e0b 100644 --- a/crates/vim/src/normal.rs +++ b/crates/vim/src/normal.rs @@ -30,7 +30,7 @@ use editor::scroll::Autoscroll; use editor::{Anchor, SelectionEffects}; use editor::{display_map::ToDisplayPoint, movement}; use gpui::{Context, Window, actions}; -use language::{Point, SelectionGoal, ToPoint}; +use language::{Point, SelectionGoal}; use log::error; use multi_buffer::MultiBufferRow; @@ -663,38 +663,42 @@ impl Vim { Vim::take_forced_motion(cx); self.update_editor(window, cx, |vim, editor, _window, cx| { let selection = editor.selections.newest_anchor(); - if let Some((_, buffer, _)) = editor.active_excerpt(cx) { - let filename = if let Some(file) = buffer.read(cx).file() { - if count.is_some() { - if let Some(local) = file.as_local() { - local.abs_path(cx).to_string_lossy().to_string() - } else { - file.full_path(cx).to_string_lossy().to_string() - } + let Some((buffer, point, _)) = editor + .buffer() + .read(cx) + .point_to_buffer_point(selection.head(), cx) + else { + return; + }; + let filename = if let Some(file) = buffer.read(cx).file() { + if count.is_some() { + if let Some(local) = file.as_local() { + local.abs_path(cx).to_string_lossy().to_string() } else { - file.path().to_string_lossy().to_string() + file.full_path(cx).to_string_lossy().to_string() } } else { - "[No Name]".into() - }; - let buffer = buffer.read(cx); - let snapshot = buffer.snapshot(); - let lines = buffer.max_point().row + 1; - let current_line = selection.head().text_anchor.to_point(&snapshot).row; - let percentage = current_line as f32 / lines as f32; - let modified = if buffer.is_dirty() { " [modified]" } else { "" }; - vim.status_label = Some( - format!( - "{}{} {} lines --{:.0}%--", - filename, - modified, - lines, - percentage * 100.0, - ) - .into(), - ); - cx.notify(); - } + file.path().to_string_lossy().to_string() + } + } else { + "[No Name]".into() + }; + let buffer = buffer.read(cx); + let lines = buffer.max_point().row + 1; + let current_line = point.row; + let percentage = current_line as f32 / lines as f32; + let modified = if buffer.is_dirty() { " [modified]" } else { "" }; + vim.status_label = Some( + format!( + "{}{} {} lines --{:.0}%--", + filename, + modified, + lines, + percentage * 100.0, + ) + .into(), + ); + cx.notify(); }); }