Skip to content

Commit 2b55acf

Browse files
committed
feat: make it possible to disable the cursor hack
1 parent cc10945 commit 2b55acf

File tree

4 files changed

+56
-27
lines changed

4 files changed

+56
-27
lines changed

src/editor/mod.rs

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::{
2323
renderer::{DrawCommand, WindowDrawCommand},
2424
running_tracker::RunningTracker,
2525
settings::Settings,
26-
window::{UserEvent, WindowCommand},
26+
window::{UserEvent, WindowCommand, WindowSettings},
2727
};
2828

2929
#[cfg(target_os = "macos")]
@@ -553,32 +553,34 @@ impl Editor {
553553
}
554554
}
555555

556-
if let Some(Window {
557-
window_type: WindowType::Message { .. },
558-
..
559-
}) = window
560-
{
561-
// When the user presses ":" to type a command, the cursor is sent to the gutter
562-
// in position 1 (right after the ":"). In all other cases, we want to skip
563-
// positioning to avoid confusing movements.
564-
let intentional = grid_left == 1;
565-
// If the cursor was already in this message, we can still move within it.
566-
let already_there = self.cursor.parent_window_id == grid;
567-
// This ^ check alone is a bit buggy though, since it fails when the cursor is
568-
// technically still in the edit window but "temporarily" at the cmdline. (#1207)
569-
let using_cmdline = self
570-
.current_mode_index
571-
.map(|current| current == MODE_CMDLINE)
572-
.unwrap_or(false);
573-
574-
if !intentional && !already_there && !using_cmdline {
575-
trace!(
576-
"Cursor unexpectedly sent to message buffer {} ({}, {})",
577-
grid,
578-
grid_left,
579-
grid_top
580-
);
581-
return;
556+
if self.settings.get::<WindowSettings>().cursor_hack {
557+
if let Some(Window {
558+
window_type: WindowType::Message { .. },
559+
..
560+
}) = window
561+
{
562+
// When the user presses ":" to type a command, the cursor is sent to the gutter
563+
// in position 1 (right after the ":"). In all other cases, we want to skip
564+
// positioning to avoid confusing movements.
565+
let intentional = grid_left == 1;
566+
// If the cursor was already in this message, we can still move within it.
567+
let already_there = self.cursor.parent_window_id == grid;
568+
// This ^ check alone is a bit buggy though, since it fails when the cursor is
569+
// technically still in the edit window but "temporarily" at the cmdline. (#1207)
570+
let using_cmdline = self
571+
.current_mode_index
572+
.map(|current| current == MODE_CMDLINE)
573+
.unwrap_or(false);
574+
575+
if !intentional && !already_there && !using_cmdline {
576+
trace!(
577+
"Cursor unexpectedly sent to message buffer {} ({}, {})",
578+
grid,
579+
grid_left,
580+
grid_top
581+
);
582+
return;
583+
}
582584
}
583585
}
584586

src/renderer/cursor_renderer/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ impl CursorRenderer {
345345
dt: f32,
346346
) -> bool {
347347
tracy_zone!("cursor_animate");
348+
if !self.cursor.enabled {
349+
return false;
350+
}
348351
let settings = self.settings.get::<CursorSettings>();
349352

350353
if settings.vfx_mode != self.previous_vfx_mode {

src/window/settings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct WindowSettings {
3333
pub input_macos_option_key_is_meta: OptionAsMeta,
3434
pub input_ime: bool,
3535
pub show_border: bool,
36+
pub cursor_hack: bool,
3637

3738
#[cfg(target_os = "windows")]
3839
pub title_background_color: String,
@@ -79,6 +80,7 @@ impl Default for WindowSettings {
7980
observed_lines: None,
8081
observed_columns: None,
8182
show_border: false,
83+
cursor_hack: true,
8284

8385
#[cfg(target_os = "windows")]
8486
title_background_color: "".to_string(),

website/docs/configuration.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,28 @@ vim.g.neovide_profiler = false
676676
Setting this to `v:true` enables the profiler, which shows a frametime graph in the upper left
677677
corner.
678678

679+
#### Cursor hack
680+
681+
VimScript:
682+
683+
```vim
684+
let g:neovide_cursor_hack = v:true
685+
```
686+
687+
Lua:
688+
689+
```lua
690+
vim.g.neovide_cursor_hack = true
691+
```
692+
693+
**Unreleased yet.**
694+
695+
Prevents the cursor from flickering to the command line when it shouldn't. This will be disabled by
696+
default when Neovim properly sends the UI busy events and the hack is no longer needed. NOTE: In
697+
some cases the hack itself is buggy and prevents the cursor from moving to the command line when it
698+
should. In that case you can try to disable it, especially if you are not using cursor animations
699+
and the flickering does not bother as much.
700+
679701
### Input Settings
680702

681703
#### macOS Option Key is Meta

0 commit comments

Comments
 (0)