Skip to content

Commit

Permalink
Enable IntelliSense prediction by default (#3351)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxian-dbw committed Jun 22, 2022
1 parent 60a48d6 commit 2ef36fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions PSReadLine/Cmdlets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public class PSConsoleReadLineOptions
/// </summary>
public const int DefaultAnsiEscapeTimeout = 100;

public PSConsoleReadLineOptions(string hostName)
public PSConsoleReadLineOptions(string hostName, bool usingLegacyConsole)
{
ResetColors();
EditMode = DefaultEditMode;
Expand All @@ -185,7 +185,11 @@ public PSConsoleReadLineOptions(string hostName)
HistorySearchCaseSensitive = DefaultHistorySearchCaseSensitive;
HistorySaveStyle = DefaultHistorySaveStyle;
AnsiEscapeTimeout = DefaultAnsiEscapeTimeout;
PredictionSource = DefaultPredictionSource;
PredictionSource = usingLegacyConsole
? PredictionSource.None
: Environment.Version.Major < 6
? PredictionSource.History
: PredictionSource.HistoryAndPlugin;
PredictionViewStyle = DefaultPredictionViewStyle;
MaximumHistoryCount = 0;

Expand Down
5 changes: 3 additions & 2 deletions PSReadLine/KeyBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ void SetDefaultWindowsBindings()
{ Keys.AltMinus, MakeKeyHandler(DigitArgument, "DigitArgument") },
{ Keys.AltQuestion, MakeKeyHandler(WhatIsKey, "WhatIsKey") },
{ Keys.AltA, MakeKeyHandler(SelectCommandArgument, "SelectCommandArgument") },
{ Keys.AltH, MakeKeyHandler(ShowParameterHelp, "ShowParameterHelp") },
{ Keys.F1, MakeKeyHandler(ShowCommandHelp, "ShowCommandHelp") },
{ Keys.F2, MakeKeyHandler(SwitchPredictionView, "SwitchPredictionView") },
{ Keys.F3, MakeKeyHandler(CharacterSearch, "CharacterSearch") },
{ Keys.ShiftF3, MakeKeyHandler(CharacterSearchBackward, "CharacterSearchBackward") },
Expand All @@ -239,8 +241,6 @@ void SetDefaultWindowsBindings()
{ Keys.AltD, MakeKeyHandler(KillWord, "KillWord") },
{ Keys.CtrlAt, MakeKeyHandler(MenuComplete, "MenuComplete") },
{ Keys.CtrlW, MakeKeyHandler(BackwardKillWord, "BackwardKillWord") },
{ Keys.AltH, MakeKeyHandler(ShowParameterHelp, "ShowParameterHelp") },
{ Keys.F1, MakeKeyHandler(ShowCommandHelp, "ShowCommandHelp") },
};

// Some bindings are not available on certain platforms
Expand Down Expand Up @@ -338,6 +338,7 @@ void SetDefaultEmacsBindings()
{ Keys.AltA, MakeKeyHandler(SelectCommandArgument, "SelectCommandArgument") },
{ Keys.AltH, MakeKeyHandler(ShowParameterHelp, "ShowParameterHelp") },
{ Keys.F1, MakeKeyHandler(ShowCommandHelp, "ShowCommandHelp") },
{ Keys.F2, MakeKeyHandler(SwitchPredictionView, "SwitchPredictionView") },
};

// Some bindings are not available on certain platforms
Expand Down
4 changes: 3 additions & 1 deletion PSReadLine/ReadLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,9 @@ private PSConsoleReadLine()
{
hostName = PSReadLine;
}
_options = new PSConsoleReadLineOptions(hostName);

bool usingLegacyConsole = _console is PlatformWindows.LegacyWin32Console;
_options = new PSConsoleReadLineOptions(hostName, usingLegacyConsole);
_prediction = new Prediction(this);
SetDefaultBindings(_options.EditMode);
}
Expand Down

0 comments on commit 2ef36fb

Please sign in to comment.