Repository: nvaccess/nvda

Issue:
If reading a word and it contains only a symbol and white space, Read symbol irrespective of symbol level
**Reported by sumandogra on 2015-06-02 09:09**
The punctuation marks such as comma are not read with word reading commands until and unless the punctuation marks is set to all in the voce dialog box.  It is suggested to make these punctuations marks read on using word reading and character reading command irrespective of the punctuation marks level, NVDA remains silent on reaching the punctuation   Marks such as comma with word reading command if the punctuation marks is not set to all.

Steps to reproduce:
1.  Open a word document that has many punctuation marks such as commas.
2.  Read the document with word reading command.
3.  On reaching comma, NVDA remains silent.



Discussion:
Comment 1 by jteh on 2015-06-03 00:26
Doing this for all words could be undesirable for some. If the user has chosen to read a certain level of punctuation, it's reasonable to expect that this should always be the case except when reading by character. Doing otherwise could create inconsistency and confusion.

That said, we should probably make sure we speak all words as characters if they contain only a single character. We already do this in some cases, but not all.

Technical: We don't seem to speak single character words as characters if the single character is followed by a space. We should probably strip spaces before doing this test.

P3 because there's an easy workaround (change the symbol level temporarily or move by character if you hear silence when moving by word).

Implementation note: this shouldn't be too difficult. In speech.py, in speakTextInfo around line 853, we check `len(textWithFields[0])==1`. This needs to be changed so that we strip white space from `textWithFields[0]` before checking the length. Note that we shouldn't strip if the text contains only white space, since that would cause, for example, single tab characters to be silenced when moving by word.
I suggest to close this issue because the user can specify in the symbols dialog on which symbol level NVDA should report a certain symbol. So you can change the reporting behavior for Komma to be reported when you have symbols set to another setting than "all". Note that it works for example properly for dot, percent or dollar sign if you have punctuation to "some". For komma it can be adjusted accordingly.
cc: @jcsteh 
I'm not a fan of situations where you can move the focus and have NVDA report nothing, as is the case if you control+right arrow through a sentence with a comma (particularly in Word, for instance).  I agree with the proposal to have NVDA report the punctuation where it is the only text to be spoken, even if the punctuation level wouldn't have otherwise had that symbol spoken.

Resolving patch:
diff --git a/source/speech/__init__.py b/source/speech/__init__.py
--- a/source/speech/__init__.py
+++ b/source/speech/__init__.py
@@ -2,7 +2,8 @@
 # A part of NonVisual Desktop Access (NVDA)
 # This file is covered by the GNU General Public License.
 # See the file COPYING for more details.
-# Copyright (C) 2006-2020 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Babbage B.V., Bill Dengler
+# Copyright (C) 2006-2020 NV Access Limited, Peter Vágner, Aleksey Sadovoy, Babbage B.V., Bill Dengler,
+# Julien Cochuyt
 
 """High-level functions to speak information.
 """ 
@@ -1281,7 +1282,7 @@ def isControlEndFieldCommand(x):
 	if onlyInitialFields or (
 		isWordOrCharUnit
 		and len(textWithFields) > 0
-		and len(textWithFields[0]) == 1
+		and len(textWithFields[0].strip() if not textWithFields[0].isspace() else textWithFields[0]) == 1
 		and all(isControlEndFieldCommand(x) for x in itertools.islice(textWithFields, 1, None))
 	):
 		if not onlyCache:


Test patch: