Repository navigation
Description
Depending on which edit control is being used, the problem is either in UIAutomations’s Text pattern implementation or IAccessible2’s IAccessibleText implementation. Either way, the text returned for the word at the carat position is incorrect.
Here are the basic rules:
The text of words returned by the accessibility API must match keyboard word navigation (ctrl+leftArrow and ctrl+rightArrow) exactly.
The behavior of ctrl+leftArrow and ctrl+rightArrow must be symmetrical (i.e., the word breaks must not change regardless which command is used).
The placement of the carat should never be on white space, except at the end of a line
Word navigation should stop at all punctuation marks
Here is a line from a file I’m working in. I started at the beginning of the line and I placed vertical bars (|) where the ctrl+rightArrow stops.
import| {| NamedSFC| }| from| '../../|common|/react|/named|-sfc|';|
based on this, the words returned by the accessibility API should be:
“import”
“ {”
“ NamedSFC”
“ }”
“ from”
“ '../../”
“common”
“/react”
“/named”
“-sfc”
“';”
If this doesn’t look right to you, good. The places where the keyboard stops, and thus what is considered a word, make no sense. And as a coder myself, I find these word breaks not useful because I am often placed on space characters. That would be a problem even if I weren’t using an access technology.
I would arrange the words in the line this way:
“import “
“{ “
“NamedSFC “
“} “
“from “
“'”
“..”
“/”
“..”
“/”
“common”
“/”
“react”
“/”
“named”
“-“
“sfc”
“'”
“;”
Visual studio breaks up the line this way, which is also acceptable:
“import “
{ “
NamedSFC “
“} “
“from “
“'../../”
“common”
“/”
“react”
“/”
“named”
“-“
“sfc”
“’;”
Furthermore, the behavior of ctrl+leftArrow and ctrl+rightArrow in VSCode is not symmetrical. For example, here are the word breaks starting from the left and moving right:
from| ‘../../|common
Here are the line breaks for the fragment starting at the end and moving to the left.
from |‘../../|common
Notice the positioning of the line break between “from” and “’” has changed. That is disorienting.
Activity
isidorn commentedon Feb 13, 2020
Rob Gallo (@RobGallo) thanks a lot for providing feedback.
I just tried this and could not reproduce the exact behavior you are seeing.
Do you have
"editor.accessibilitySupport": "on"turned on in your settings?What I am seeing is that
ctrl + leftandctrl + rightare symetrical. They do not navigate ideally as in your example, but navigate the only way that NVDA properly reads the whole line.Please note that you can configure between two word navigation behaviors, we have
cursorWordAccessibilityRightandcursorWordRight. You can navigate between what to use by simple disabling keybinding assigned to them in the File > Preferences > Keyboard Shortcuts menu.When we detect that a screen reader is used on Windows we automatically switch to an "accessible" way of navigating words. The reason we do that is becuase NVDA expects that words get navigated in a way Chrome navigates them (because VS Code is detected as a Chrome app). So when we detect the Screen Reader
cursorWordAccessibilityRighttakes precendece over the regularcursorWordRight.We first have to check if any of those navigation commands work for you.
Since the
cursorWordAccessibilityRightworks for all our NVDA users, however it might not be good for JAWS.Thus I would like if you experiment with both. And if none work we can look into introducing a different one. I would just have to check if we can detect what screen reader is attached to distinguish between Jaws and NVDA.
Same what I just said for
cursorWordAccessibilityRightalso holds for following commands:cursorWordAccessibilityLeft-cursorWordLeftcursorWordAccessibilityLeftSelect-cursorWordLeftSelectcursorWordAccessibilityRightSelect-cursorWordRightSelectOnce you try this out let us know and we can works on a PR that will improve this.
Thanks!
fyi Neuronne Derek Riemer (@derekriemer)
RobGallo commentedon Feb 14, 2020
Isidor Nikolic (@isidorn)
I'd like to challenge your assertion that, "...the cursorWordAccessibilityRight works for all our NVDA users..." The text editing in VSCode does not behave like any other editor I have used on Windows. If there is a screen reader user out there who finds this behavior satisfactory, I'd like for them to please chime in to this conversation so I can understand what they expect from the next and prior word commands.
NVDA and JAWS work identically in the code I tested; so there does not appear to be much difference between the screen readers.
editor.accessibilitySupport was set to auto, And I can tell that the screen reader is being detected by VSCode. Even still, I change the setting to "on". No change.
I also disabled editor.accessibilitySupport to see if the default navigation worked better, but I found them to be basically the same.
"...but navigate the only way that NVDA properly reads the whole line..."
What is the relevance of the line here?
VSCode does seem to be providing the expected text at word boundaries from IAccessibleText.textAtOffset based on cursor navigation most of the time. The problem is that the cursor boundaries themselves are largely unexpected. As I mentioned in my original message, the cursor needs to stop at each punctuation mark when moving by character. Check out Visual Studio to see what it does.
Here are two specific suggestions to get started:
When the cursor stops on white space, the textAtOffset() function should return only white space.
You can see this problem by moving the cursor to the end of any line. NVDA will announce the previous word boundary, not the white space.
When navigating by word, two consecutive white space characters should always be skipped, even if the two characters are different.
You can see this problem if you move to the end of a line of text which is followed by a blank line, then more text. The cursor will land on the blank line, and that should never happen.
Lastly, my original message is part of this conversation, but as an image. Any other screen reader user who wants to read it, can't.
isidorn commentedon Feb 18, 2020
Rob Gallo (@RobGallo) first of all sorry for the slow reponse and thanks for your reply.
editor.accessibilitySupportshould change how word navigation behaves.. Are you not seeing any difference at all, or simple both do not work for you?textAtOffset()function, since VS Code is built on top of Electron which is built on top of Chromium we can not control this.vscode/src/vs/editor/contrib/wordOperations/wordOperations.ts
Line 193 in 33e78e0
I appologize for the image in the orginal message, I made the mistake of Copying from Outlook who copies to the clipboard as an image. I have fixed the original message to be text.
webczat commentedon Feb 18, 2020
In my experience it was reading more than it should. when I would navigate word by word I would hear parts of next line when being at the end of the previous line, if I remember correctly.
RobGallo commentedon Feb 18, 2020
ahicks92 commentedon Mar 7, 2020
I am having similar issues. Going to start here. Word navigation with C++ will be i.e.
foo->. Navigating over a function will repeat the whole function back as a word multiple times, i.e.foo() {and seems to sometimes not be moving through it. Sometimes move by word includes the next line. Sometimes selecting when moving by word selects parts of the next line.The net result is I spend a lot of time second guessing word navigation and making sure it did what I want it to have done. Additionally this issue explains why configuring word separators doesn't take effect, I believe (which was the first thing I tried).
Will try the above suggestions.
ahicks92 commentedon Mar 7, 2020
Firstly I'm on NVDA. Should have said.
I tried the above on the line
and it's actually kind of hard to tell what's going on. Selection announcement is always accurate in the sense that it's not reporting things that aren't selected, but definitely acts surprising. Disabling the accessibility versions of selection fixes selection to be roughly what I'd expect, and still lets NVDA announce correctly.
Disabling the accessible versions of word navigation however doesn't fix word navigation. It fixes word navigation to do what it should but the announcement of the current word is massively incorrect.
Even with the accessible version of word navigation, the following code snippet is broken:
as "false;\n}" is reported as a word 3 times as opposed to as separate entities.
Perhaps someone knows if/how hard it'd be to get the NVDA side of things playing nice here, because I'm not sure that this can be fixed in VSCode itself either, and it'd be really amazing to have this working. There's small ergonomics issues beyond this but even with this bug VSCode is enough of a good value proposition that I'm using it.
isidorn commentedon Mar 12, 2020
@camlorn first of all thanks a lot for your feedback and sorry fo the slow response.
We can fine tune the word navigation in VS Code however we want. However that will probalby not fix the overall issue. The problem is how NVDA expectes word navgiation is done as in Chrome.
I am open to changing the word navigatino in whatever way we think is best and will work best for each Screen Reader separatly.
Leonard de Ruijter (@LeonarddeR) this is actually the biggest NVDA - VS Code issue which we would love to fix the most.
José Vilmar Estácio de Souza (@jvesouza) Andy Borka (@ajborka) are you happy with Word Navigation using Orca? Can you give it a spin and provide feedback so we try to get to a concensus here.
LeonarddeR commentedon Mar 12, 2020
Strange enough, I"m unable to reproduce this with a11y mode on. It looks like things have improved lately, is this true?
The following example:
int cheese = 3; // CommentReads the following, as expected to where the cursor is positioned:
ajborka commentedon Mar 12, 2020
Isidor Nikolic (@isidorn) , word navigation in the editor works according to the standard Linux conventions. So, looks like everything is good to go here.
69 remaining items
isidorn commentedon Feb 24, 2021
Austin Hicks (@ahicks92) vscode provides the option to customize word navigation however for that to work with NVDA, NVDA has to fix this issue nvaccess/nvda#12091
Please comment there. Thanks
RobGallo commentedon Feb 24, 2021
Isidor Nikolic (@isidorn) How does one customize word navigation please?
isidorn commentedon Feb 24, 2021
Rob Gallo (@RobGallo) you can change the following setting
"editor.wordSeparators"That is a list of separators that basically define a word.
However until NVDA fixes that issue we ignore this list of separators on Windows when a screen reader is detected and we fall back to Chrome native word navigation. This setting is respected on other platforms for example macOS with VoiceOver or Linux with Orca.
Also there are mutliple commands to navigate words, you can try mutliple of them and try to find the right one. Just go to Preferences > keyboard shortcuts and type "cursorWord" - you can then find a list of keybindings for these various commands or you can assign your own keybinding.
Also there are probably lots of extensions that add cursor navigation - however I did not explore tthis at all. I just noticed there is an extension called "subword navigation".
But the important thing: with NVDA none of those cursor navigations will read the right thing, only the native chrome word navigation will read things properly - which we do by default.
LeonarddeR commentedon Feb 25, 2021
I'm happy to look into this further, but pointed out the following in nvaccess/nvda#12091 (comment)
Also note that the behavior of ctrl+leftArrow and ctrl+rightArrow isn't symmetrical in Chrome.
isidorn commentedon Feb 25, 2021
Leonard de Ruijter (@LeonarddeR) great, for the NVDA fix let's continue the discussion in the NVDA issue. Thanks!
RobGallo commentedon Feb 25, 2021
I should point out that it is not NVDA or JAWS or any other screen reader where problems lie or where fixes should be made. The problem, the actual, fundamental problem, is in Chrome.
The problem we're discussing occurs when the word boundaries for keyboard navigation and text retrieval through IAccessibleText are not consistent. In other words, if the number of characters jumped when moving by word with the keyboard does not equal the number of characters returned when retrieving text at the word boundary through IAccessibleText, a screen reader user will receive either more or fewer characters than are visually represented by a word on screen.
The problem has two parts:
IAccessibleText supports retrieving text from an edit field by a specified boundary type, e.g., character, word, line, paragraph, etc. So when a screen reader reads the word at the cursor, this is how it is done:
When navigating by word, the following occurs:
You will notice in the above description that the application is entirely responsible for both moving the cursor by word and determining what text is within the word boundary when requested through the IAccessibleText interface. Ergo, the problem needs to be fixed in the application, in this case Chrome. Modifying NVDA and/or VSCode may cover over the problem, but it isn't an actual fix.
ahicks92 commentedon Feb 27, 2021
The insiders build helps, but I've got other weird examples now:
Skips the
(when reading by word from left to right, but not when reading from right to left. And:Reads
->twice when going from left to right, rather than readingread. When going from right to left, it's fine.This is the following insiders version:
isidorn commentedon Mar 1, 2021
Austin Hicks (@ahicks92) thanks for sharing those example. Both examples are already covered with this issue I have created last week https://bugs.chromium.org/p/chromium/issues/detail?id=1181643
So please comment on it so we get some movement by the Google engineers. Hopefully they can fix it on their side and once they do we would just cherry-pick the fix onto vs code.
Thanks!
chore: pick up latest electron v11.3.0