diff --git a/src/Microsoft.PowerShell.PSReadLine/KeyBindings.cs b/src/Microsoft.PowerShell.PSReadLine/KeyBindings.cs index aae97e503e..b543aef8a1 100644 --- a/src/Microsoft.PowerShell.PSReadLine/KeyBindings.cs +++ b/src/Microsoft.PowerShell.PSReadLine/KeyBindings.cs @@ -114,6 +114,25 @@ namespace Microsoft.PowerShell private Dictionary _dispatchTable; private Dictionary> _chordDispatchTable; + /// + /// Helper to set bindings based on EditMode + /// + void SetDefaultBindings(EditMode editMode) + { + switch (editMode) + { + case EditMode.Emacs: + SetDefaultEmacsBindings(); + break; + case EditMode.Vi: + SetDefaultViBindings(); + break; + case EditMode.Windows: + SetDefaultWindowsBindings(); + break; + } + } + void SetDefaultWindowsBindings() { _dispatchTable = new Dictionary(new ConsoleKeyInfoComparer()) diff --git a/src/Microsoft.PowerShell.PSReadLine/Options.cs b/src/Microsoft.PowerShell.PSReadLine/Options.cs index d8162b743f..b927282e27 100644 --- a/src/Microsoft.PowerShell.PSReadLine/Options.cs +++ b/src/Microsoft.PowerShell.PSReadLine/Options.cs @@ -96,18 +96,7 @@ namespace Microsoft.PowerShell // Switching/resetting modes - clear out chord dispatch table _chordDispatchTable.Clear(); - switch (options._editMode) - { - case EditMode.Emacs: - SetDefaultEmacsBindings(); - break; - case EditMode.Vi: - SetDefaultViBindings(); - break; - case EditMode.Windows: - SetDefaultWindowsBindings(); - break; - } + SetDefaultBindings(Options.EditMode); } if (options._showToolTips.HasValue) {