Skip to content
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

Do not erase a modified line when moving in the Python console history #16654

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions source/pythonConsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ def __init__(self, parent):
self.inputCtrl.SetFont(font)
self.inputCtrl.Bind(wx.EVT_CHAR, self.onInputChar)
self.inputCtrl.Bind(wx.EVT_TEXT_PASTE, self.onInputPaste)
self.inputCtrl.Bind(wx.EVT_TEXT, self.onInputTextChange)
self.inputTextModified = False
inputSizer.Add(self.inputCtrl, proportion=1, flag=wx.EXPAND)
mainSizer.Add(inputSizer, proportion=1, flag=wx.EXPAND)
self.SetSizer(mainSizer)
Expand Down Expand Up @@ -374,13 +376,17 @@ def execute(self):
self.outputPositions.append(self.outputCtrl.GetInsertionPoint())

def historyMove(self, movement):
if self.inputTextModified:
self.inputHistoryPos = len(self.inputHistory) - 1
self.inputHistory[self.inputHistoryPos] = self.inputCtrl.GetValue()
newIndex = self.inputHistoryPos + movement
if not (0 <= newIndex < len(self.inputHistory)):
# No more lines in this direction.
return False
self.inputHistoryPos = newIndex
self.inputCtrl.ChangeValue(self.inputHistory[newIndex])
self.inputCtrl.SetInsertionPointEnd()
self.inputTextModified = False
return True

RE_COMPLETE_UNIT = re.compile(r"[\w.]*$")
Expand Down Expand Up @@ -516,6 +522,10 @@ def onInputPaste(self, evt):
self.inputCtrl.ChangeValue(suffix)
break

def onInputTextChange(self, evt: wx.CommandEvent):
self.inputTextModified = True
evt.Skip()

def onOutputKeyDown(self, evt):
key = evt.GetKeyCode()
# #3763: WX 3 no longer passes escape to evt_char for richEdit fields, therefore evt_key_down is used.
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Unicode CLDR has been updated.
* The fallback braille input table is now equal to the fallback output table, which is Unified English Braille Code grade 1. (#9863, @JulienCochuyt, @LeonarddeR)
* NVDA will now report figures with no accessible children, but with a label or description. (#14514)
* When reading by line in browse mode, "caption" is no longer reported on each line of a long figure or table caption. (#14874)
* In the Python console, the last unexecuted command will no longer be lost when moving in the input history. (#16653, @CyrilleB79)

### Bug Fixes
* Windows 11 fixes:
Expand Down