Skip to content

Commit 6a06476

Browse files
tigTylerLeonhardt
andauthored
ENTER now moves to list if on filter (#98)
* Fixed #58: Multi-line commands rendering wrong * Fixed #58 - Newlines in commands render incorrectly * Added debug instructions to readme * Update src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs Co-Authored-By: Tyler James Leonhardt <[email protected]> * simplified stripping of newline/linefeed * ENTER now moves to list if on filter Co-authored-by: Tyler James Leonhardt <[email protected]>
1 parent ad01f86 commit 6a06476

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Microsoft.PowerShell.ConsoleGuiTools/ConsoleGui.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ internal class ConsoleGui : IDisposable
1616
private const string FILTER_LABEL = "Filter";
1717
private bool _cancelled;
1818
private GridViewDataSource _itemSource;
19+
private TextField _filterField;
1920
private ListView _listView;
2021
private ApplicationData _applicationData;
2122
private GridViewDetails _gridViewDetails;
@@ -100,7 +101,14 @@ private void AddStatusBar()
100101
// Use Key.Unknown for SPACE with no delegate because ListView already
101102
// handles SPACE
102103
new StatusItem(Key.Unknown, "~SPACE~ Mark Item", null),
103-
new StatusItem(Key.Enter, "~ENTER~ Accept", () => Accept()),
104+
new StatusItem(Key.Enter, "~ENTER~ Accept", () => {
105+
if (Application.Top.MostFocused == _listView){
106+
Accept();
107+
}
108+
else if (Application.Top.MostFocused == _filterField){
109+
Application.Top.SetFocus(_listView);
110+
}
111+
}),
104112
new StatusItem(Key.Esc, "~ESC~ Close", () => Close())
105113
}
106114
: new StatusItem []
@@ -169,7 +177,7 @@ private void AddFilter(Window win)
169177
X = 2
170178
};
171179

172-
var filterField = new TextField(string.Empty)
180+
_filterField = new TextField(string.Empty)
173181
{
174182
X = Pos.Right(filterLabel) + 1,
175183
Y = Pos.Top(filterLabel),
@@ -185,7 +193,7 @@ private void AddFilter(Window win)
185193
Width = Dim.Fill() - filterLabel.Text.Length
186194
};
187195

188-
filterField.Changed += (object sender, ustring e) =>
196+
_filterField.Changed += (object sender, ustring e) =>
189197
{
190198
// NOTE: `ustring e` seems to contain the text _before_ the added character...
191199
// so we convert the `sender` into a TextField and grab the text from that.
@@ -208,7 +216,7 @@ private void AddFilter(Window win)
208216
}
209217
};
210218

211-
win.Add(filterLabel, filterField, filterErrorLabel);
219+
win.Add(filterLabel, _filterField, filterErrorLabel);
212220
}
213221

214222
private void AddHeaders(Window win, List<string> gridHeaders)

0 commit comments

Comments
 (0)