mltony / nvda-indent-nav

GNU General Public License v2.0
13 stars 5 forks source link

Assumption of an app module is causing AttributeError #21

Closed cartertemm closed 5 months ago

cartertemm commented 5 months ago

In some programs, like Notepad2 or any other application where there is no product name for the active app module, the addon is erroring out when trying to determine whether VSCode is focused. Traceback is as follows:

error executing script: <bound method EditableIndentNav.script_moveToPreviousSibling of <NVDAObjects.Dynamic_ScintillaIAccessibleScintillaWindowNVDAObjectEditableIndentNav object at 0x2422A2F0>> with gesture 'alt+NVDA+up arrow'
Traceback (most recent call last):
  File "scriptHandler.pyc", line 295, in executeScript
  File "C:\users\username\AppData\Roaming\nvda\addons\IndentNav\globalPlugins\indent_nav\__init__.py", line 1672, in script_moveToPreviousSibling
    self.move(-1, [msgEditable])
  File "C:\users\username\AppData\Roaming\nvda\addons\IndentNav\globalPlugins\indent_nav\__init__.py", line 1717, in move
    self.moveInEditable(increment, errorMessages[0], unbounded, op, speakOnly=speakOnly, moveCount=moveCount, excludeFilterRegex=excludeFilterRegex)
  File "C:\users\username\AppData\Roaming\nvda\addons\IndentNav\globalPlugins\indent_nav\__init__.py", line 1721, in moveInEditable
    with self.getLineManager() as lm:
  File "C:\users\username\AppData\Roaming\nvda\addons\IndentNav\globalPlugins\indent_nav\__init__.py", line 993, in __enter__
    document = self.obj.makeEnhancedTextInfo(textInfos.POSITION_ALL, allowPlainTextInfoInVSCode=legacyVSCode)
  File "C:\users\username\AppData\Roaming\nvda\addons\IndentNav\globalPlugins\indent_nav\__init__.py", line 1999, in makeEnhancedTextInfo
    if not self.isVscodeApp():
  File "C:\users\username\AppData\Roaming\nvda\addons\IndentNav\globalPlugins\indent_nav\__init__.py", line 1975, in isVscodeApp
    return self.appModule.productName.startswith("Visual Studio Code")
AttributeError: 'NoneType' object has no attribute 'startswith'

This should be an easy fix, just check to see whether the productName is of type None. If so, convert it to a string.