Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion src/Terminal.Gui.Editor/Editor.Drawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
}
13 changes: 13 additions & 0 deletions tests/Terminal.Gui.Editor.IntegrationTests/EditorRenderingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EditorTestHost> 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 ()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Terminal.Gui.Editor.IntegrationTests/EditorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading