Skip to content

Commit 2ef36fb

Browse files
authored
Enable IntelliSense prediction by default (#3351)
1 parent 60a48d6 commit 2ef36fb

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

PSReadLine/Cmdlets.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class PSConsoleReadLineOptions
165165
/// </summary>
166166
public const int DefaultAnsiEscapeTimeout = 100;
167167

168-
public PSConsoleReadLineOptions(string hostName)
168+
public PSConsoleReadLineOptions(string hostName, bool usingLegacyConsole)
169169
{
170170
ResetColors();
171171
EditMode = DefaultEditMode;
@@ -185,7 +185,11 @@ public PSConsoleReadLineOptions(string hostName)
185185
HistorySearchCaseSensitive = DefaultHistorySearchCaseSensitive;
186186
HistorySaveStyle = DefaultHistorySaveStyle;
187187
AnsiEscapeTimeout = DefaultAnsiEscapeTimeout;
188-
PredictionSource = DefaultPredictionSource;
188+
PredictionSource = usingLegacyConsole
189+
? PredictionSource.None
190+
: Environment.Version.Major < 6
191+
? PredictionSource.History
192+
: PredictionSource.HistoryAndPlugin;
189193
PredictionViewStyle = DefaultPredictionViewStyle;
190194
MaximumHistoryCount = 0;
191195

PSReadLine/KeyBindings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ void SetDefaultWindowsBindings()
230230
{ Keys.AltMinus, MakeKeyHandler(DigitArgument, "DigitArgument") },
231231
{ Keys.AltQuestion, MakeKeyHandler(WhatIsKey, "WhatIsKey") },
232232
{ Keys.AltA, MakeKeyHandler(SelectCommandArgument, "SelectCommandArgument") },
233+
{ Keys.AltH, MakeKeyHandler(ShowParameterHelp, "ShowParameterHelp") },
234+
{ Keys.F1, MakeKeyHandler(ShowCommandHelp, "ShowCommandHelp") },
233235
{ Keys.F2, MakeKeyHandler(SwitchPredictionView, "SwitchPredictionView") },
234236
{ Keys.F3, MakeKeyHandler(CharacterSearch, "CharacterSearch") },
235237
{ Keys.ShiftF3, MakeKeyHandler(CharacterSearchBackward, "CharacterSearchBackward") },
@@ -239,8 +241,6 @@ void SetDefaultWindowsBindings()
239241
{ Keys.AltD, MakeKeyHandler(KillWord, "KillWord") },
240242
{ Keys.CtrlAt, MakeKeyHandler(MenuComplete, "MenuComplete") },
241243
{ Keys.CtrlW, MakeKeyHandler(BackwardKillWord, "BackwardKillWord") },
242-
{ Keys.AltH, MakeKeyHandler(ShowParameterHelp, "ShowParameterHelp") },
243-
{ Keys.F1, MakeKeyHandler(ShowCommandHelp, "ShowCommandHelp") },
244244
};
245245

246246
// Some bindings are not available on certain platforms
@@ -338,6 +338,7 @@ void SetDefaultEmacsBindings()
338338
{ Keys.AltA, MakeKeyHandler(SelectCommandArgument, "SelectCommandArgument") },
339339
{ Keys.AltH, MakeKeyHandler(ShowParameterHelp, "ShowParameterHelp") },
340340
{ Keys.F1, MakeKeyHandler(ShowCommandHelp, "ShowCommandHelp") },
341+
{ Keys.F2, MakeKeyHandler(SwitchPredictionView, "SwitchPredictionView") },
341342
};
342343

343344
// Some bindings are not available on certain platforms

PSReadLine/ReadLine.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,9 @@ private PSConsoleReadLine()
686686
{
687687
hostName = PSReadLine;
688688
}
689-
_options = new PSConsoleReadLineOptions(hostName);
689+
690+
bool usingLegacyConsole = _console is PlatformWindows.LegacyWin32Console;
691+
_options = new PSConsoleReadLineOptions(hostName, usingLegacyConsole);
690692
_prediction = new Prediction(this);
691693
SetDefaultBindings(_options.EditMode);
692694
}

0 commit comments

Comments
 (0)