Skip to content

Commit 688c292

Browse files
tigCopilot
andauthored
Reverts #5133. Revert TableView Home/End FullRowSelect change (#5136)
* Revert "Fixes #5132. TableView Home/End navigation with FullRowSelect (#5133)" This reverts commit 6361f33. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Docs: Document Home/End rebinding for FullRowSelect in TableView Adds a tip to the FullRowSelect section showing how to rebind Home/End to Command.Start/Command.End for row-level navigation, referencing the UICatalogRunnable pattern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c50a81e commit 688c292

3 files changed

Lines changed: 15 additions & 37 deletions

File tree

Terminal.Gui/Views/TableView/TableView.Selection.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ public bool MoveCursorToEndOfRow (bool extend, ICommandContext? ctx)
3232
return false;
3333
}
3434

35-
if (FullRowSelect)
36-
{
37-
return MoveCursorToEndOfTable (extend, ctx);
38-
}
39-
4035
SetSelection (Table!.Columns - 1, _cursorRow, extend, ctx);
4136
Update ();
4237

@@ -53,11 +48,6 @@ public bool MoveCursorToStartOfRow (bool extend, ICommandContext? ctx)
5348
return false;
5449
}
5550

56-
if (FullRowSelect)
57-
{
58-
return MoveCursorToStartOfTable (extend, ctx);
59-
}
60-
6151
SetSelection (0, _cursorRow, extend, ctx);
6252
Update ();
6353

Tests/UnitTestsParallelizable/Views/TableViewBaselineTests.cs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,6 @@ public void Home_Key_MovesToStartOfRow ()
191191
Assert.Equal (0, tv.Value!.Cursor.Y); // row unchanged
192192
}
193193

194-
[Fact]
195-
public void Home_Key_FullRowSelect_MovesToFirstRow ()
196-
{
197-
// Copilot
198-
TableView tv = CreateTableView (5, 10);
199-
tv.FullRowSelect = true;
200-
tv.SetSelection (3, 5, false);
201-
202-
tv.NewKeyDownEvent (Key.Home);
203-
Assert.Equal (3, tv.Value!.Cursor.X);
204-
Assert.Equal (0, tv.Value!.Cursor.Y);
205-
}
206-
207194
[Fact]
208195
public void End_Key_MovesToEndOfRow ()
209196
{
@@ -215,19 +202,6 @@ public void End_Key_MovesToEndOfRow ()
215202
Assert.Equal (0, tv.Value!.Cursor.Y); // row unchanged
216203
}
217204

218-
[Fact]
219-
public void End_Key_FullRowSelect_MovesToLastRow ()
220-
{
221-
// Copilot
222-
TableView tv = CreateTableView (5, 10);
223-
tv.FullRowSelect = true;
224-
tv.SetSelection (1, 5, false);
225-
226-
tv.NewKeyDownEvent (Key.End);
227-
Assert.Equal (1, tv.Value!.Cursor.X);
228-
Assert.Equal (9, tv.Value!.Cursor.Y);
229-
}
230-
231205
[Fact]
232206
public void MoveCursorToStartOfTable_MovesToOrigin ()
233207
{

docfx/docs/tableview.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ Extended regions (`IsExtended = true`) persist through keyboard navigation. Non-
124124

125125
When `FullRowSelect` is `true`, entire rows are selected instead of individual cells. All cells in the cursor's row are reported as selected by `GetAllSelectedCells ()` and `IsSelected ()`.
126126

127+
> **Tip — Home/End with FullRowSelect:** By default, `Home` and `End` navigate to the
128+
> start/end of the current *row* (i.e. first/last column). To make `Home`/`End` jump to
129+
> the first/last *row* instead (which is often more useful in full-row mode), rebind them
130+
> to `Command.Start` and `Command.End`:
131+
>
132+
> ```csharp
133+
> tableView.KeyBindings.Remove (Key.Home);
134+
> tableView.KeyBindings.Add (Key.Home, Command.Start);
135+
> tableView.KeyBindings.Remove (Key.End);
136+
> tableView.KeyBindings.Add (Key.End, Command.End);
137+
> ```
138+
>
139+
> This is the pattern used by `UICatalogRunnable` for its scenario list.
140+
127141
### Reading the Selection
128142
129143
```csharp
@@ -148,7 +162,7 @@ bool sel = tv.IsSelected (col, row);
148162
| Arrow keys | Move cursor one cell |
149163
| Shift+Arrow | Extend selection |
150164
| PageUp / PageDown | Move one page |
151-
| Home / End | Move to start/end of row. With `FullRowSelect`, move to first/last row |
165+
| Home / End | Move to start/end of row |
152166
| Ctrl+Home / Ctrl+End | Move to first/last row |
153167
| Shift+Home/End/Ctrl+Home/Ctrl+End | Extend selection to row/table boundary |
154168
| Ctrl+A | Select all |

0 commit comments

Comments
 (0)