diff --git a/Terminal.Gui/Views/TableView/TableView.Selection.cs b/Terminal.Gui/Views/TableView/TableView.Selection.cs index 0298b0787b..6a994a1912 100644 --- a/Terminal.Gui/Views/TableView/TableView.Selection.cs +++ b/Terminal.Gui/Views/TableView/TableView.Selection.cs @@ -32,6 +32,11 @@ public bool MoveCursorToEndOfRow (bool extend, ICommandContext? ctx) return false; } + if (FullRowSelect) + { + return MoveCursorToEndOfTable (extend, ctx); + } + SetSelection (Table!.Columns - 1, _cursorRow, extend, ctx); Update (); @@ -48,6 +53,11 @@ public bool MoveCursorToStartOfRow (bool extend, ICommandContext? ctx) return false; } + if (FullRowSelect) + { + return MoveCursorToStartOfTable (extend, ctx); + } + SetSelection (0, _cursorRow, extend, ctx); Update (); diff --git a/Tests/UnitTestsParallelizable/Views/TableViewBaselineTests.cs b/Tests/UnitTestsParallelizable/Views/TableViewBaselineTests.cs index 74828bbc04..89939bd96f 100644 --- a/Tests/UnitTestsParallelizable/Views/TableViewBaselineTests.cs +++ b/Tests/UnitTestsParallelizable/Views/TableViewBaselineTests.cs @@ -191,6 +191,19 @@ public void Home_Key_MovesToStartOfRow () Assert.Equal (0, tv.Value!.Cursor.Y); // row unchanged } + [Fact] + public void Home_Key_FullRowSelect_MovesToFirstRow () + { + // Copilot + TableView tv = CreateTableView (5, 10); + tv.FullRowSelect = true; + tv.SetSelection (3, 5, false); + + tv.NewKeyDownEvent (Key.Home); + Assert.Equal (3, tv.Value!.Cursor.X); + Assert.Equal (0, tv.Value!.Cursor.Y); + } + [Fact] public void End_Key_MovesToEndOfRow () { @@ -202,6 +215,19 @@ public void End_Key_MovesToEndOfRow () Assert.Equal (0, tv.Value!.Cursor.Y); // row unchanged } + [Fact] + public void End_Key_FullRowSelect_MovesToLastRow () + { + // Copilot + TableView tv = CreateTableView (5, 10); + tv.FullRowSelect = true; + tv.SetSelection (1, 5, false); + + tv.NewKeyDownEvent (Key.End); + Assert.Equal (1, tv.Value!.Cursor.X); + Assert.Equal (9, tv.Value!.Cursor.Y); + } + [Fact] public void MoveCursorToStartOfTable_MovesToOrigin () { diff --git a/docfx/docs/tableview.md b/docfx/docs/tableview.md index 625ccc6ce7..d0b92f2f58 100644 --- a/docfx/docs/tableview.md +++ b/docfx/docs/tableview.md @@ -148,7 +148,7 @@ bool sel = tv.IsSelected (col, row); | Arrow keys | Move cursor one cell | | Shift+Arrow | Extend selection | | PageUp / PageDown | Move one page | -| Home / End | Move to start/end of row | +| Home / End | Move to start/end of row. With `FullRowSelect`, move to first/last row | | Ctrl+Home / Ctrl+End | Move to first/last row | | Shift+Home/End/Ctrl+Home/Ctrl+End | Extend selection to row/table boundary | | Ctrl+A | Select all |