Repository: nvaccess/nvda

Issue:
Control+Delete doesn't report the word being deleted
<!--
Please thoroughly read NVDA's wiki article on how to fill in this template, including how to provide the required files.
Issues may be closed if the required information is not present.
https://github.com/nvaccess/nvda/wiki/Github-issue-template-explanation-and-examples
-->

### Steps to reproduce:
Simply open a Word document, a file in Wordpad, a new message in Thunderbird, etc. and start typing some words. Move a few words backwards via Control+Left. Now try deleting words to the right of the cursor with Control+Delete.
### Actual behavior:
NVDA remains silent as each word gets deleted via Control+Delete.
### Expected behavior:
NVDA should echo the deleted word, or the portion of it which is being deleted.
### System configuration
#### NVDA installed/portable/running from source:
Installed
#### NVDA version:
alpha-20005,14c2e2ec, but also reproducable with 2019.3.1.
#### Windows version:
Win 10 Pro 64-Bit Version 2004 (OS Build 19041.207)
#### Name and version of other software in use when reproducing the issue:

#### Other information about your system:

### 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.
Up to 2019.3 and 2019.3.1.
#### If addons are disabled, is your problem still occuring?
Yes
#### Did you try to run the COM registry fixing tool in NVDA menu / tools?
No, as it doesn't presumably affect this issue.



Discussion:
sure. It happens the same even in my Microsoft-Wore. for me, not only CTRL+Delete but also CTRL+backspace. no deleted word is spoken whether by pressing CTRL+Delete or CTRL+backspace. when pressing these hot keys, they should echo the deleted word. for instance, if you delete the word this by pressing CTRL+backspace, NVDA should say "delete back word this; when pressing CTRL+Delete, NVDA should say, Delete forward word this.
I have a feeling this is because the caret does not move when using ctrl + delete, however it does when pressing ctrl+backspace. 
Quite interestingly, the NVDA Global Plug-in, an NVDA Add-on, has an option for fixing this which works very well.
I just want to mention that addon has some fixes but it is not an official addon and has not passed the review. That addon is very comprehensive and has other conflicts with different NVDA features, key strokes etc. This addon is used only by a limited number of users worldwide.
So I hope the issue is fixed via NVDA itself in the near future.
Perhaps someone can look at how that add-on fixes the problem and submit a PR.
Hi,
I am the author of this add-on and I am very attentive to any report of 
problems encountered by it use.
However, I have not so far reported to you those you mentioned.
Those reported during the review for acceptance by the community were 
resolved long ago.
If there are any left, I will be happy to correct them.
You said:
 >This addon is used only by a limited number of users worldwide.
I would like to know how you measure it and is this statement really 
valid to judge the value or usefulness of an add-on?
Best regards.
Sorry for my bad english (Principal problem for review aggrement)
Paul.
@paulber19 please don't start add-on review discussions here. The NVDA add-on mailing list is a better place to have this conversation and ask these questions. Of course you can link to this issue to give people context. I'm going to hide these comments to keep discussion on track.
OK. I understand.
I'm very sorry.
Please also hide the email to which I replied.
Best regards.
Paul.
Le 01/05/2020 10:51, Reef Turner a écrit :
>
> @paulber19 <https://github.com/paulber19> please don't start add-on 
> review discussions here. The NVDA add-on mailing list is a better 
> place to have this conversation and ask these questions. Of course you 
> can link to this issue to give people context. I'm going to hide these 
> comments to keep discussion on track.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub 
> <https://github.com/nvaccess/nvda/issues/11029#issuecomment-622306350>, or 
> unsubscribe 
> <https://github.com/notifications/unsubscribe-auth/ADZLFFBNGV74FRYVNIWWOBDRPKERNANCNFSM4MLO2XKA>.
>



Resolving patch:
diff --git a/source/editableText.py b/source/editableText.py
--- a/source/editableText.py
+++ b/source/editableText.py
@@ -1,8 +1,7 @@
-#editableText.py
-#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-2017 NV Access Limited, Davy Kager
+# 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, Davy Kager, Julien Cochuyt
 
 """Common support for editable text.
 @note: If you want editable text functionality for an NVDAObject,
@@ -267,7 +266,7 @@ def script_caret_backspaceCharacter(self,gesture):
 	def script_caret_backspaceWord(self,gesture):
 		self._backspaceScriptHelper(textInfos.UNIT_WORD,gesture)
 
-	def script_caret_delete(self,gesture):
+	def _deleteScriptHelper(self, unit, gesture):
 		try:
 			info=self.makeTextInfo(textInfos.POSITION_CARET)
 		except:
@@ -279,9 +278,15 @@ def script_caret_delete(self,gesture):
 		gesture.send()
 		# We'll try waiting for the caret to move, but we don't care if it doesn't.
 		caretMoved,newInfo=self._hasCaretMoved(bookmark,origWord=word)
-		self._caretScriptPostMovedHelper(textInfos.UNIT_CHARACTER,gesture,newInfo)
+		self._caretScriptPostMovedHelper(unit, gesture, newInfo)
 		braille.handler.handleCaretMove(self)
 
+	def script_caret_deleteCharacter(self, gesture):
+		self._deleteScriptHelper(textInfos.UNIT_CHARACTER, gesture)
+
+	def script_caret_deleteWord(self, gesture):
+		self._deleteScriptHelper(textInfos.UNIT_WORD, gesture)
+
 	__gestures = {
 		"kb:upArrow": "caret_moveByLine",
 		"kb:downArrow": "caret_moveByLine",
@@ -299,8 +304,10 @@ def script_caret_delete(self,gesture):
 		"kb:end": "caret_moveByCharacter",
 		"kb:control+home": "caret_moveByLine",
 		"kb:control+end": "caret_moveByLine",
-		"kb:delete": "caret_delete",
-		"kb:numpadDelete": "caret_delete",
+		"kb:delete": "caret_deleteCharacter",
+		"kb:numpadDelete": "caret_deleteCharacter",
+		"kb:control+delete": "caret_deleteWord",
+		"kb:control+numpadDelete": "caret_deleteWord",
 		"kb:backspace": "caret_backspaceCharacter",
 		"kb:control+backspace": "caret_backspaceWord",
 	}


Test patch: