diff --git a/src/Terminal.Gui.Editor/Editor.Drawing.cs b/src/Terminal.Gui.Editor/Editor.Drawing.cs index e3f82e9..caa7172 100644 --- a/src/Terminal.Gui.Editor/Editor.Drawing.cs +++ b/src/Terminal.Gui.Editor/Editor.Drawing.cs @@ -362,6 +362,10 @@ private void UpdateCursor () } Point screen = ViewportToScreen (new Point (col, row)); - Cursor = new Cursor { Position = screen, Style = CursorStyle.BlinkingBar }; + Cursor = Cursor with + { + Position = screen, + Style = Cursor.Style == CursorStyle.Hidden ? CursorStyle.Default : Cursor.Style + }; } } diff --git a/tests/Terminal.Gui.Editor.IntegrationTests/EditorRenderingTests.cs b/tests/Terminal.Gui.Editor.IntegrationTests/EditorRenderingTests.cs index 086a452..c26d94c 100644 --- a/tests/Terminal.Gui.Editor.IntegrationTests/EditorRenderingTests.cs +++ b/tests/Terminal.Gui.Editor.IntegrationTests/EditorRenderingTests.cs @@ -330,6 +330,19 @@ public async Task Cursor_Position_After_Tab_Uses_Expanded_Tab_Columns () Assert.Equal (new Point (4, 0), fx.Top.Editor.Cursor.Position); } + [Fact] + public async Task Cursor_Style_Is_Preserved_When_Position_Updates () + { + await using AppFixture fx = new (() => new EditorTestHost ("abc")); + fx.Top.Editor.SetFocus (); + fx.Top.Editor.Cursor = new Cursor { Style = CursorStyle.SteadyUnderline }; + fx.Top.Editor.CaretOffset = 2; + fx.Render (); + + Assert.Equal (new Point (2, 0), fx.Top.Editor.Cursor.Position); + Assert.Equal (CursorStyle.SteadyUnderline, fx.Top.Editor.Cursor.Style); + } + [Fact] public async Task Highlighted_Tokens_Follow_The_Active_Scheme () { diff --git a/tests/Terminal.Gui.Editor.IntegrationTests/EditorTests.cs b/tests/Terminal.Gui.Editor.IntegrationTests/EditorTests.cs index f107037..233a054 100644 --- a/tests/Terminal.Gui.Editor.IntegrationTests/EditorTests.cs +++ b/tests/Terminal.Gui.Editor.IntegrationTests/EditorTests.cs @@ -531,6 +531,6 @@ public async Task Primary_Caret_Is_Visible_After_Exiting_MultiCaret () // The primary caret is the terminal cursor. After dismissing the block it must still be // drawn (visible, not the hidden default cursor) and positioned on the primary offset. - Assert.Equal (CursorStyle.BlinkingBar, fx.Top.Editor.Cursor.Style); + Assert.True (fx.Top.Editor.Cursor.IsVisible); } }