Repository: nvaccess/nvda

Issue:
Python console - The caret moves to left when pressing upArrow
Surely a little and low priority bug.

### Steps to reproduce:

1. Restart NVDA
2. Press NVDA+ctrl+Z to open Python console
3. Type the following lines (press Enter to validate at the end)
   `a='Hello'`
   `b=a`
4. Press upArrow two times
5. Press upArrow a few more times

### Actual behavior:

At step 4. you land at the end of the two lines you had already entered before. This is expected.
At step 5. the first line is still on the prompt line, what is expected. But each time you press upArrow, the caret moves one character to the left.

### Expected behavior:

At step 5. the caret should remain at the end of the line.

### System configuration
#### NVDA installed/portable/running from source:
Installed
#### NVDA version:
2021.1rc2
#### Windows version:
Windows 10 2004 (64-bit) build 19041.388
#### Name and version of other software in use when reproducing the issue:
N/A
#### Other information about your system:
N/A
### Other questions
#### Does the issue still occur after restarting your computer?
Yes
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
2020.4 has the same issue. And probably also older versions from what I remember.
#### If add-ons are disabled, is your problem still occurring?
Yes
#### Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?
Not tested, but probably nothing to do with it.



Discussion:
cc: @JulienCochuyt 
This is not specific to the Python console and occurs with most standard Win32 edit controls which are not multiline. It can also be reproduced for example in the properties window for a shortcut when pressing up arrow in the "start in" edit field. @CyrilleB79  Can you confirm? If so shall we close this as either invalid or needs external fix (I don't think reporting this to MS would result in a fix but who knows)
@lukaszgo1 thanks for your comment that helps understanding this issue.
I have tested the single line edit field in a shortcut property window. And I confirm that up and down arrows act as left and right arrow respectively.
I think that it is not a bug from MS but a feature. Indeed, in a single line edit field usual actions of up and down arrows to move to previous or next line would not make sense since the field contains only one line. Thus they rather act as left and right arrows. And actually, the Narrator reads character by character when using up or down arrows in single line edit fields. I guess NVDA should behave the same way, what would allow to understand what really happens.

Regarding the console input edit field, I think that a multi-line edit field should be used even if it contains and shows only one line at a time. This would make more sense since up and down arrows are used to navigate in a multi-line buffer, what is more similar to a multi-line text content.
If for any other technical reason a single-line edit field should be kept, we should ensure in any case that the default up/down arrow actions are always overriden to avoid left/right navigation. But this would cause problems if we implement Narrator's behaviour in single-line edit fields one day.







Resolving patch:
diff --git a/source/pythonConsole.py b/source/pythonConsole.py
--- a/source/pythonConsole.py
+++ b/source/pythonConsole.py
@@ -409,8 +409,8 @@ def onInputChar(self, evt):
 			self.execute()
 			return
 		elif key in (wx.WXK_UP, wx.WXK_DOWN):
-			if self.historyMove(-1 if key == wx.WXK_UP else 1):
-				return
+			self.historyMove(-1 if key == wx.WXK_UP else 1)
+			return
 		elif key == wx.WXK_F6:
 			self.outputCtrl.SetFocus()
 			return


Test patch: