-
Notifications
You must be signed in to change notification settings - Fork 320
Fix System.ArgumentOutOfRangeException while get-tab #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
5d11156
6aedc7d
c08e171
3c72b87
a395af3
33b2ba6
2f57fe5
88976f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -483,17 +483,25 @@ void EnsureMenuAndInputIsVisible(IConsole console, int tooltipLineCount) | |
| } | ||
| } | ||
|
|
||
| public void DrawMenu(Menu previousMenu) | ||
| public void DrawMenu(Menu previousMenu, bool menuSelect) | ||
| { | ||
| IConsole console = Singleton._console; | ||
|
|
||
| // Move cursor to the start of the first line after our input. | ||
| this.Top = Singleton.ConvertOffsetToPoint(Singleton._buffer.Length).Y + 1; | ||
| EnsureMenuAndInputIsVisible(console, tooltipLineCount: 0); | ||
| if (menuSelect) | ||
| { | ||
| // Move cursor to the start of the first line after our input. | ||
| this.Top = Singleton.ConvertOffsetToPoint(Singleton._buffer.Length).Y + 1; | ||
| EnsureMenuAndInputIsVisible(console, tooltipLineCount: 0); | ||
|
|
||
| console.CursorVisible = false; | ||
| console.SaveCursor(); | ||
| console.SetCursorPosition(0, this.Top); | ||
| console.CursorVisible = false; | ||
| console.SaveCursor(); | ||
| console.SetCursorPosition(0, this.Top); | ||
| } | ||
| else | ||
| { | ||
| // Start a new line to show the menu contents | ||
| console.Write("\n"); | ||
| } | ||
|
|
||
| var bufferWidth = console.BufferWidth; | ||
| var columnWidth = this.ColumnWidth; | ||
|
|
@@ -532,8 +540,18 @@ public void DrawMenu(Menu previousMenu) | |
| } | ||
| } | ||
|
|
||
| console.RestoreCursor(); | ||
| console.CursorVisible = true; | ||
| if (menuSelect) | ||
| { | ||
| console.RestoreCursor(); | ||
| console.CursorVisible = true; | ||
| } | ||
| else | ||
| { | ||
| // Update the cursor coordinates after showing the menu. | ||
|
||
| _singleton._initialX = console.CursorLeft; | ||
| _singleton._initialY = console.CursorTop; | ||
| _singleton._previousRender = _initialPrevRender; | ||
| } | ||
| } | ||
|
|
||
| public void Clear() | ||
|
|
@@ -591,7 +609,8 @@ public void UpdateMenuSelection(int selectedItem, bool select, bool showTooltips | |
| } | ||
| } | ||
|
|
||
| if (BufferLines + Rows + toolTipLines > console.WindowHeight) | ||
| // The +1 is for a new line after showing the tool tips | ||
| if ((Top + Rows + toolTipLines + 1) > console.WindowHeight) | ||
| { | ||
| showTooltips = false; | ||
| } | ||
|
|
@@ -742,8 +761,8 @@ private void PossibleCompletionsImpl(CommandCompletion completions, bool menuSel | |
| } | ||
| else | ||
| { | ||
| menu.DrawMenu(null); | ||
| InvokePrompt(key: null, arg: menu.Top + menu.Rows); | ||
| menu.DrawMenu(null, menuSelect:false); | ||
| InvokePrompt(key: null, arg: _console.CursorTop); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -790,7 +809,7 @@ private void MenuCompleteImpl(Menu menu, CommandCompletion completions) | |
| var userInitialCompletionLength = userCompletionText.Length; | ||
|
|
||
| completions.CurrentMatchIndex = 0; | ||
| menu.DrawMenu(null); | ||
| menu.DrawMenu(null, menuSelect:true); | ||
|
|
||
| bool processingKeys = true; | ||
| int previousSelection = -1; | ||
|
|
@@ -821,7 +840,7 @@ private void MenuCompleteImpl(Menu menu, CommandCompletion completions) | |
| if (topAdjustment != 0) | ||
| { | ||
| menu.Top += topAdjustment; | ||
| menu.DrawMenu(null); | ||
| menu.DrawMenu(null, menuSelect:true); | ||
| } | ||
| if (topAdjustment > 0) | ||
| { | ||
|
|
@@ -898,7 +917,7 @@ private void MenuCompleteImpl(Menu menu, CommandCompletion completions) | |
| { | ||
| var newMenu = menuStack.Pop(); | ||
|
|
||
| newMenu.DrawMenu(menu); | ||
| newMenu.DrawMenu(menu, menuSelect:true); | ||
| previousSelection = -1; | ||
|
|
||
| menu = newMenu; | ||
|
|
@@ -960,7 +979,7 @@ private void MenuCompleteImpl(Menu menu, CommandCompletion completions) | |
| { | ||
| var newMenu = CreateCompletionMenu(newMatches); | ||
|
|
||
| newMenu.DrawMenu(menu); | ||
| newMenu.DrawMenu(menu, menuSelect:true); | ||
| previousSelection = -1; | ||
|
|
||
| // Remember the current menu for when we see Backspace. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could write over some of the buffer if you press Tab anywhere that is not the last line, e.g.:
After pressing Tab Tab, the screen might look like:
When it should look like:
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jason, I submitted the fix and tested it. It seems working fine now. Please take a look it again. Thanks!