Is your feature request related to a problem? Please describe.
The problem is the one my IgnoreBlanksIndentationReporting addon aims to solve. It is described in the readme, but I will also rephrase it herefor full context.
Line indentation reporting is a very useful feature in NVDA, particularly for programmers since indentation is an important part of formatting code and in some languages like python it can even affect the meaning of the code. However, in its current form it can be too noisy by announcing indentation changes in contexts when it is not useful.
To explain the last point, consider this code fragment:
def foo():
x = 42
return x
def bar():
The current behaviour of NVDA is to report indentation changes for any line where the indentation has changed, even if the line is blank. So, the example would be read like:
def foo():
tab x = 42
no indent blank
tab return x
no indent blank
def bar():
The disadvantage for this behaviour is that for most programming languages, like python, a blank line has no semantic significance and is just used to visually separate lines of code with no change to the code's meaning. Therefore, by reporting the change of indentation upon entering a blank line and then reporting it again after landing on the next line is just noise that makes it harder to focus on understanding the code.
Describe the solution you'd like
To increase the signal to noise ratio in situations like the one described above, it would be good if settings would have a toggle like "Announce indentation changes on blank lines". By default it would be on, since that is the current behavior. When toggled off, it would result in the above code fragment read as:
def foo():
tab x = 42
blank
return x
no indent def bar():
In this case, indentation changes are announced 2 times instead of 4 and each time it is semantically significant to understanding the code, as opposed to the default behavior.
This behavior can be implemented quite simply and I would be happy to contribute a pull request. Inside speech.speech the getTextInfoSpeech function decides whether to announce an indentation change with this if:
if reportIndentation and speakTextInfoState and allIndentation!=speakTextInfoState.indentationCache:
The IgnoreBlanksIndentationAddon changes this behavior so it does not announce the indentation change for a blank line by altering it to this:
isNotBlank = any(isinstance(t, str) and not all(c in LINE_END_CHARS for c in t) for t in textWithFields)
if reportIndentation and speakTextInfoState and isNotBlank and allIndentation!=speakTextInfoState.indentationCache:
Note: LINE_END_Chars is defined as LINE_END_CHARS = { '\r', '\n' }
Since the proposed solution is to implement it as a native NVDA toggleable feature, it would differ from the addon implementation by also taking into account if the setting is toggled on/off, but otherwise it wouldn't require other changes to work.
Describe alternatives you've considered
The alternative is the aforementioned addon I developed. The major flaw with the addon implementation is that since the logic whether to announce indentation changes is buried in the getTextInfoSpeech function, to override this behavior, the addon must perform a monkey patch and replace getTextInfoSpeech with a copy where the only change is the aforementioned if statement.
The consequence of this is that any time there is any change in getTextInfoSpeech, no matter how minor or whether it is in any way related to indentation reporting, the addon has to be updated to also handle the new NVDA version, by defining a new version of the function with the one line change. The addon has to check the NVDA version and select the correct version of the monkey patched function. Supporting older versions of NVDA along with future releases will grow in complexity if the function is ever significantly restructured.
Is your feature request related to a problem? Please describe.
The problem is the one my IgnoreBlanksIndentationReporting addon aims to solve. It is described in the readme, but I will also rephrase it herefor full context.
Line indentation reporting is a very useful feature in NVDA, particularly for programmers since indentation is an important part of formatting code and in some languages like python it can even affect the meaning of the code. However, in its current form it can be too noisy by announcing indentation changes in contexts when it is not useful.
To explain the last point, consider this code fragment:
The current behaviour of NVDA is to report indentation changes for any line where the indentation has changed, even if the line is blank. So, the example would be read like:
The disadvantage for this behaviour is that for most programming languages, like python, a blank line has no semantic significance and is just used to visually separate lines of code with no change to the code's meaning. Therefore, by reporting the change of indentation upon entering a blank line and then reporting it again after landing on the next line is just noise that makes it harder to focus on understanding the code.
Describe the solution you'd like
To increase the signal to noise ratio in situations like the one described above, it would be good if settings would have a toggle like "Announce indentation changes on blank lines". By default it would be on, since that is the current behavior. When toggled off, it would result in the above code fragment read as:
In this case, indentation changes are announced 2 times instead of 4 and each time it is semantically significant to understanding the code, as opposed to the default behavior.
This behavior can be implemented quite simply and I would be happy to contribute a pull request. Inside
speech.speechthegetTextInfoSpeechfunction decides whether to announce an indentation change with thisif:The IgnoreBlanksIndentationAddon changes this behavior so it does not announce the indentation change for a blank line by altering it to this:
Note:
LINE_END_Charsis defined asLINE_END_CHARS = { '\r', '\n' }Since the proposed solution is to implement it as a native NVDA toggleable feature, it would differ from the addon implementation by also taking into account if the setting is toggled on/off, but otherwise it wouldn't require other changes to work.
Describe alternatives you've considered
The alternative is the aforementioned addon I developed. The major flaw with the addon implementation is that since the logic whether to announce indentation changes is buried in the
getTextInfoSpeechfunction, to override this behavior, the addon must perform a monkey patch and replacegetTextInfoSpeechwith a copy where the only change is the aforementioned if statement.The consequence of this is that any time there is any change in
getTextInfoSpeech, no matter how minor or whether it is in any way related to indentation reporting, the addon has to be updated to also handle the new NVDA version, by defining a new version of the function with the one line change. The addon has to check the NVDA version and select the correct version of the monkey patched function. Supporting older versions of NVDA along with future releases will grow in complexity if the function is ever significantly restructured.