Repository: nvaccess/nvda

Issue:
Problem navigating paragraphs in BarahaPad Application
### Actual behavior: 
Paragraphs are announced or recognized very slow or late.

### Expected behavior:
Should be announced or recognized very quickly.

### System configuration
#### NVDA installed/portable/running from source:
Installed

#### NVDA version:
2022.2 beta

#### Windows version: Windows 11(Windows
Version 21H2 (OS Build 22000.739)) 64 bit.

#### Name and version of other software in use when reproducing the issue:
BarahaPad Application(Baraha_10.10.400 64bit)

#### Other information about your system:
Dell Inspiron 3542 64 bit Core I3 With 4GB Ram

### 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. In previous version of NVDA This Problem has not occurred.

#### If NVDA 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?
Yes.

Hello Team members, I am experiencing a strange problem in BarahaPad Application while navigating the paragraphs. BarahaPad is a popular Indian language editor. This is the only application for Indian Blind users for editing Indian Languages.
The problem is: While navigating the next or previous paragraph using `Ctrl+DownArrow` and `Ctrl+UpArrow`, The paragraphs will be announced very slowly. In previous version of NVDA We Had not seen such problem. Hope that your team definitely solve this bug. I am attaching the extra Log info of this BarahaPad Application.

[NVDA LOG Info.txt](https://github.com/nvaccess/nvda/files/8950111/NVDA.LOG.Info.txt)

Best regards.
Problem navigating paragraphs in BarahaPad Application
### Actual behavior: 
Paragraphs are announced or recognized very slow or late.

### Expected behavior:
Should be announced or recognized very quickly.

### System configuration
#### NVDA installed/portable/running from source:
Installed

#### NVDA version:
2022.2 beta

#### Windows version: Windows 11(Windows
Version 21H2 (OS Build 22000.739)) 64 bit.

#### Name and version of other software in use when reproducing the issue:
BarahaPad Application(Baraha_10.10.400 64bit)

#### Other information about your system:
Dell Inspiron 3542 64 bit Core I3 With 4GB Ram

### 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. In previous version of NVDA This Problem has not occurred.

#### If NVDA 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?
Yes.

Hello Team members, I am experiencing a strange problem in BarahaPad Application while navigating the paragraphs. BarahaPad is a popular Indian language editor. This is the only application for Indian Blind users for editing Indian Languages.
The problem is: While navigating the next or previous paragraph using `Ctrl+DownArrow` and `Ctrl+UpArrow`, The paragraphs will be announced very slowly. In previous version of NVDA We Had not seen such problem. Hope that your team definitely solve this bug. I am attaching the extra Log info of this BarahaPad Application.

[NVDA LOG Info.txt](https://github.com/nvaccess/nvda/files/8950111/NVDA.LOG.Info.txt)

Best regards.


Discussion:
@narayan-b-raikar  It looks like you have several invalid entries in your speech dictionary, while it is unlikely they're causing the issue you may want to look into it.
But, I never experienced such problem in previous virsions of NVDA like v 2021.3.5 or v 2021.2 or older. I am seing this from NVDA V 2022.2 beta1. I thought that, this bug may be solve in next beta update. But, after downloading and Testing of NVDA V 2022.2 beta2, I am experiencing Same problem. I also tested Alpha snapshots. But, Still I am facing the same problem.

It appears that you are cycling through synthesizers every sentence. What is the synthDriver `ibmeci`? IBM eloquence?

Can you produce a [log file](https://github.com/nvaccess/nvda/wiki/LogFilesAndCrashDumps) with the following set up:
- log level set to DEBUG
- nothing in your ["Developer scratchpad directory"](https://www.nvaccess.org/files/nvda/releases/2022.1/documentation/userGuide.html#AdvancedSettings)
- NVDA restarted with add-ons disabled
I am using E-speak synthesizer for my Hindi text. I didn't set different voice for each sentences. Now I reproduced the log info with suggested setup. And including this. I have prepared 2 different log files. First one is with disabled addons, second one is with enabled debugging log. Thank you.

[Nvda log info with Addons disabled.txt](https://github.com/nvaccess/nvda/files/9000942/Nvda.log.info.with.Addons.disabled.txt)
[Nvda log info with debug log enabled.txt](https://github.com/nvaccess/nvda/files/9000943/Nvda.log.info.with.debug.log.enabled.txt)


@narayan-b-raikar - for future logs, please have both add-ons disabled, and debug log enabled. You can enable debug logging from General preferences.

In the log with debug logging enabled, I am noticing differences of 4 seconds between ``control+downArrow`` presses and speech starting. Is this the instance of lag occurring?

I wonder if NVDA changing languages to process punctuation is causing this. Can you reproduce this with "Automatic language switching" disabled in [Speech Settings](https://www.nvaccess.org/files/nvda/releases/2022.1/documentation/userGuide.html#SpeechSettings).

```py
Input: kb(desktop):control+downArrow
DEBUG - editableText.EditableText._hasCaretMoved (17:43:22.248) - MainThread (8240):
Caret move detected using bookmarks. Elapsed: 0 ms
IO - speech.speech.speak (17:43:26.954) - MainThread (8240):
Speaking [LangChangeCommand ('en_GB'), '( ', LangChangeCommand ('hi_IN'), 'उप ०', LangChangeCommand ('en_GB'), ') ', LangChangeCommand ('hi_IN'), 'इदानीं भूतानां लक्षणानि गन्धादीनि परीचिक्षिषुर्गन्धादीनां स्वाभाविकत्वमौपाधिकत्वञ्च व्यवस्थापयन्नाह ', LangChangeCommand ('en_GB'), '- ', LangChangeCommand ('hi_IN'), 'पुष्पवस्त्रयोरिति। रूपरसगन्धस्पर्शा यत्र कारणगुणप्रक्रमेणोत्पद्यन्ते तत्र स्वाभाविकाः सन्तो लक्षणतामुपयान्ति', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'नान्यथा। न हि समीरणे उपलभ्यमानं सौरभम्', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'शिलातले उपलभ्यमानं शैत्यम्', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'जले उपलभ्यमानमौष्ण्यं वा लक्षणं भवति', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'तदेतदाह पुष्पवस्त्रयोरिति। न हि कनककेतकीकुसुमसन्निकृष्टे वाससि कनककेतकीसौरभमुपलभ्यमानं वाससः। न हि वाससः कारणगुणप्रक्रमेण तदुत्पन्नम्। किंतर्हि कनककेतकीसन्निधानादौपाधिकम्', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'न हि वस्त्रे गन्धाभावे केतकीगन्धाभावो लिङ्गम्। किं लिङ्गमत उक्तं गुणान्तराप्रादुर्भाव इति। गुणान्तरात् कारणगुणादप्रादुर्भावोऽनुत्पत्तिः। यदि हि वस्त्रे यो गन्ध उपलभ्यते स तस्य स्वाभाविकः स्यात्तदा तदवयवेषु तन्तुषु केतकीसन्निकर्षात्पूर्व तत्र वस्त्रे चोपलभ्येत', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'न चैवमित्यर्थः। तथा च विवादाध्यासितो गन्धो न वस्त्रसमवेतः तदवयवगुणाजन्यविशेषगुणत्वाच्छीतोष्णस्पर्शादिवत् ॥१ ॥', LangChangeCommand ('en_GB'), '\r']
IO - inputCore.InputManager.executeGesture (17:43:35.581) - winInputHook (6988):
Input: kb(desktop):control+end
```
Yes, I am facing this problem while pressing CTRL+DownnErro-Ctrl+UpErro. Now I completely restored my NVDA configuration setting, disabled automatic language switching, Enabled debugging log and kept other setting their default state. But, Still I am facing same issue. I never faced such problem till NVDA V 2021.3.5. When I updated to V 2022.1, I am facing this.  As your suggestion, again I reproduced Log information. I am including this now.

And another thing, I am using E-speak synthosizer with nepali voice for Sanskrit text, which is in hindi script. Because, There is no any synthosizer or voice for Sanskrit language. But, Nepali voice can read quitely Sanskrit text with correct pronunciation. But, This is the not problem for my issue. Because,  I also tested this with other Indian language Like, Kannada, Marathi etc. But, still I experiencing same issue.


[Nvda Log info with debugging enabled, Automatic language switching disabled.txt](https://github.com/nvaccess/nvda/files/9007163/Nvda.Log.info.with.debugging.enabled.Automatic.language.switching.disabled.txt)



In the last comment you said: 
> I never faced such problem till NVDA V 2021.3.5. When I updated to V 2022.1, I am facing this. 

But in the earlier comment you said:

> I am seing this from NVDA V 2022.2 beta1.

Could you please tell us which version introduced this issue 2022.1 or 2022.2?

If 2022.1 is okay this can be possibly caused by #13618

Sorry for the my last comment. actually, I was facing another problem after updating NVDA 2022.1. That was Related to StartAllBack application ListView. That issue was solved in NVDA 2022.2 Beta1. But, From NVDA 2022.2 Beta1, I am experiencing This paragraph navigation latency issue. I was confused while submiting my last comment. Once again, I apologize for my mistake.

Thank you.
@narayan-b-raikar  It looks like you have several invalid entries in your speech dictionary, while it is unlikely they're causing the issue you may want to look into it.
But, I never experienced such problem in previous virsions of NVDA like v 2021.3.5 or v 2021.2 or older. I am seing this from NVDA V 2022.2 beta1. I thought that, this bug may be solve in next beta update. But, after downloading and Testing of NVDA V 2022.2 beta2, I am experiencing Same problem. I also tested Alpha snapshots. But, Still I am facing the same problem.

It appears that you are cycling through synthesizers every sentence. What is the synthDriver `ibmeci`? IBM eloquence?

Can you produce a [log file](https://github.com/nvaccess/nvda/wiki/LogFilesAndCrashDumps) with the following set up:
- log level set to DEBUG
- nothing in your ["Developer scratchpad directory"](https://www.nvaccess.org/files/nvda/releases/2022.1/documentation/userGuide.html#AdvancedSettings)
- NVDA restarted with add-ons disabled
I am using E-speak synthesizer for my Hindi text. I didn't set different voice for each sentences. Now I reproduced the log info with suggested setup. And including this. I have prepared 2 different log files. First one is with disabled addons, second one is with enabled debugging log. Thank you.

[Nvda log info with Addons disabled.txt](https://github.com/nvaccess/nvda/files/9000942/Nvda.log.info.with.Addons.disabled.txt)
[Nvda log info with debug log enabled.txt](https://github.com/nvaccess/nvda/files/9000943/Nvda.log.info.with.debug.log.enabled.txt)


@narayan-b-raikar - for future logs, please have both add-ons disabled, and debug log enabled. You can enable debug logging from General preferences.

In the log with debug logging enabled, I am noticing differences of 4 seconds between ``control+downArrow`` presses and speech starting. Is this the instance of lag occurring?

I wonder if NVDA changing languages to process punctuation is causing this. Can you reproduce this with "Automatic language switching" disabled in [Speech Settings](https://www.nvaccess.org/files/nvda/releases/2022.1/documentation/userGuide.html#SpeechSettings).

```py
Input: kb(desktop):control+downArrow
DEBUG - editableText.EditableText._hasCaretMoved (17:43:22.248) - MainThread (8240):
Caret move detected using bookmarks. Elapsed: 0 ms
IO - speech.speech.speak (17:43:26.954) - MainThread (8240):
Speaking [LangChangeCommand ('en_GB'), '( ', LangChangeCommand ('hi_IN'), 'उप ०', LangChangeCommand ('en_GB'), ') ', LangChangeCommand ('hi_IN'), 'इदानीं भूतानां लक्षणानि गन्धादीनि परीचिक्षिषुर्गन्धादीनां स्वाभाविकत्वमौपाधिकत्वञ्च व्यवस्थापयन्नाह ', LangChangeCommand ('en_GB'), '- ', LangChangeCommand ('hi_IN'), 'पुष्पवस्त्रयोरिति। रूपरसगन्धस्पर्शा यत्र कारणगुणप्रक्रमेणोत्पद्यन्ते तत्र स्वाभाविकाः सन्तो लक्षणतामुपयान्ति', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'नान्यथा। न हि समीरणे उपलभ्यमानं सौरभम्', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'शिलातले उपलभ्यमानं शैत्यम्', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'जले उपलभ्यमानमौष्ण्यं वा लक्षणं भवति', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'तदेतदाह पुष्पवस्त्रयोरिति। न हि कनककेतकीकुसुमसन्निकृष्टे वाससि कनककेतकीसौरभमुपलभ्यमानं वाससः। न हि वाससः कारणगुणप्रक्रमेण तदुत्पन्नम्। किंतर्हि कनककेतकीसन्निधानादौपाधिकम्', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'न हि वस्त्रे गन्धाभावे केतकीगन्धाभावो लिङ्गम्। किं लिङ्गमत उक्तं गुणान्तराप्रादुर्भाव इति। गुणान्तरात् कारणगुणादप्रादुर्भावोऽनुत्पत्तिः। यदि हि वस्त्रे यो गन्ध उपलभ्यते स तस्य स्वाभाविकः स्यात्तदा तदवयवेषु तन्तुषु केतकीसन्निकर्षात्पूर्व तत्र वस्त्रे चोपलभ्येत', LangChangeCommand ('en_GB'), ', ', LangChangeCommand ('hi_IN'), 'न चैवमित्यर्थः। तथा च विवादाध्यासितो गन्धो न वस्त्रसमवेतः तदवयवगुणाजन्यविशेषगुणत्वाच्छीतोष्णस्पर्शादिवत् ॥१ ॥', LangChangeCommand ('en_GB'), '\r']
IO - inputCore.InputManager.executeGesture (17:43:35.581) - winInputHook (6988):
Input: kb(desktop):control+end
```
Yes, I am facing this problem while pressing CTRL+DownnErro-Ctrl+UpErro. Now I completely restored my NVDA configuration setting, disabled automatic language switching, Enabled debugging log and kept other setting their default state. But, Still I am facing same issue. I never faced such problem till NVDA V 2021.3.5. When I updated to V 2022.1, I am facing this.  As your suggestion, again I reproduced Log information. I am including this now.

And another thing, I am using E-speak synthosizer with nepali voice for Sanskrit text, which is in hindi script. Because, There is no any synthosizer or voice for Sanskrit language. But, Nepali voice can read quitely Sanskrit text with correct pronunciation. But, This is the not problem for my issue. Because,  I also tested this with other Indian language Like, Kannada, Marathi etc. But, still I experiencing same issue.


[Nvda Log info with debugging enabled, Automatic language switching disabled.txt](https://github.com/nvaccess/nvda/files/9007163/Nvda.Log.info.with.debugging.enabled.Automatic.language.switching.disabled.txt)



In the last comment you said: 
> I never faced such problem till NVDA V 2021.3.5. When I updated to V 2022.1, I am facing this. 

But in the earlier comment you said:

> I am seing this from NVDA V 2022.2 beta1.

Could you please tell us which version introduced this issue 2022.1 or 2022.2?

If 2022.1 is okay this can be possibly caused by #13618

Sorry for the my last comment. actually, I was facing another problem after updating NVDA 2022.1. That was Related to StartAllBack application ListView. That issue was solved in NVDA 2022.2 Beta1. But, From NVDA 2022.2 Beta1, I am experiencing This paragraph navigation latency issue. I was confused while submiting my last comment. Once again, I apologize for my mistake.

Thank you.

Resolving patch:
diff --git a/source/NVDAObjects/window/edit.py b/source/NVDAObjects/window/edit.py
--- a/source/NVDAObjects/window/edit.py
+++ b/source/NVDAObjects/window/edit.py
@@ -684,17 +684,24 @@ def getTextWithFields(self, formatConfig: Optional[Dict] = None) -> textInfos.Te
 			formatConfig=config.conf["documentFormatting"]
 		textRange=self._rangeObj.duplicate
 		textRange.collapse(True)
+		if not formatConfig["detectFormatAfterCursor"]:
+			textRange.expand(comInterfaces.tom.tomCharacter)
+			return [
+				textInfos.FieldCommand(
+					"formatChange",
+					self._getFormatFieldAtRange(textRange, formatConfig)
+				),
+				self._getTextAtRange(self._rangeObj)
+			]
 		commandList=[]
 		endLimit=self._rangeObj.end
 		while textRange.end<endLimit:
 			self._expandFormatRange(textRange, formatConfig)
-			# Only add formatting and text if it is not marked as hidden.
-			# e.g. hyperLinks have hidden text at their beginning.
-			if not textRange.font.hidden:
-				commandList.append(
-					textInfos.FieldCommand("formatChange", self._getFormatFieldAtRange(textRange, formatConfig))
-				)
-				commandList.append(self._getTextAtRange(textRange))
+			commandList.append(textInfos.FieldCommand(
+				"formatChange",
+				self._getFormatFieldAtRange(textRange, formatConfig)
+			))
+			commandList.append(self._getTextAtRange(textRange))
 			end = textRange.end
 			textRange.start = end
 			#Trying to set the start past the end of the document forces both start and end back to the previous offset, so catch this
@@ -772,13 +779,6 @@ def move(self,unit,direction,endPoint=None):
 		else:
 			moveFunc=self._rangeObj.Move
 		res=moveFunc(unit,direction)
-		if not endPoint:
-			# For a normal move, I.e. not moving just one end,
-			# skip over any hidden text.
-			# E.g. hyperlinks have some hidden text at their beginning.
-			# So that the review cursor does not navigate through this text.
-			while res and self._rangeObj.font.hidden:
-				res = moveFunc(unit, 1 if direction > 0 else -1)
 		return res
 
 	def _get_bookmark(self):


Test patch: