Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim: Fix ignoring cursor_shape settings #25439

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions crates/vim/src/vim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use anyhow::Result;
use collections::HashMap;
use editor::{
movement::{self, FindRange},
Anchor, Bias, Editor, EditorEvent, EditorMode, ToPoint,
Anchor, Bias, Editor, EditorEvent, EditorMode, EditorSettings, ToPoint,
};
use gpui::{
actions, impl_actions, Action, App, AppContext as _, Axis, Context, Entity, EventEmitter,
Expand Down Expand Up @@ -996,7 +996,7 @@ impl Vim {
count
}

pub fn cursor_shape(&self) -> CursorShape {
pub fn cursor_shape(&self, cx: &mut App) -> CursorShape {
match self.mode {
Mode::Normal => {
if let Some(operator) = self.operator_stack.last() {
Expand All @@ -1022,7 +1022,10 @@ impl Vim {
Mode::HelixNormal | Mode::Visual | Mode::VisualLine | Mode::VisualBlock => {
CursorShape::Block
}
Mode::Insert => CursorShape::Bar,
Mode::Insert => {
let editor_settings = EditorSettings::get_global(cx);
editor_settings.cursor_shape.unwrap_or_default()
}
}
}

Expand Down Expand Up @@ -1161,15 +1164,15 @@ impl Vim {
self.store_visual_marks(window, cx);
self.clear_operator(window, cx);
self.update_editor(window, cx, |vim, editor, _, cx| {
if vim.cursor_shape() == CursorShape::Block {
if vim.cursor_shape(cx) == CursorShape::Block {
editor.set_cursor_shape(CursorShape::Hollow, cx);
}
});
}

fn cursor_shape_changed(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.update_editor(window, cx, |vim, editor, _, cx| {
editor.set_cursor_shape(vim.cursor_shape(), cx);
editor.set_cursor_shape(vim.cursor_shape(cx), cx);
});
}

Expand Down Expand Up @@ -1612,7 +1615,7 @@ impl Vim {

fn sync_vim_settings(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.update_editor(window, cx, |vim, editor, window, cx| {
editor.set_cursor_shape(vim.cursor_shape(), cx);
editor.set_cursor_shape(vim.cursor_shape(cx), cx);
editor.set_clip_at_line_ends(vim.clip_at_line_ends(), cx);
editor.set_collapse_matches(true);
editor.set_input_enabled(vim.editor_input_enabled());
Expand Down
Loading