Skip to content

Add option for ignoring blank lines for report line indentation#15057

Merged
seanbudd merged 18 commits into
nvaccess:masterfrom
SamKacer:ignoreBlankLinesForReportLineIndentation
Jul 24, 2023
Merged

Add option for ignoring blank lines for report line indentation#15057
seanbudd merged 18 commits into
nvaccess:masterfrom
SamKacer:ignoreBlankLinesForReportLineIndentation

Conversation

@SamKacer

@SamKacer SamKacer commented Jun 26, 2023

Copy link
Copy Markdown
Contributor

Link to issue number:

closes #13394

Summary of the issue:

As elaborated in #13394, line indentation reporting can be too noisy in contexts where indentation changes for blank lines aren't meaningful and distract from the actually meaningful indentation changes, such as is the case when reading source code for Python and many other programming languages.

Description of user facing changes

A new checkbox is added to Document formatting, "Ignore blank lines for line indentation reporting". By default it is off, in which case line indentation reporting behaves as it does currently. If the user ticks the checkbox, then indentation changes are not reported for blank lines.

There is also a new unassigned global command for toggling the setting.

Description of development approach

  • new config property: ignoreBlankLinesForRLI = boolean(default=false)
    • short for ignoreBlankLinesForReportLineIndentation, which was too long and causing Flake8 issues
  • new settings panel checkbox for toggling ignoreBlankLinesForRLI
  • in speech.speech.getTextInfoSpeech, if ignoreBlankLinesForRLI is true and the line is blank, the block of code that inserts the indentation announcement and updates the indentation cache is skipped, otherwise it behaves as usual
  • user guide updated with brief info on new option
  • added unassigned global command for toggling ignoreBlankLinesForRLI
  • added system test for confirming the correct behavior

Testing strategy:

I added a new test in symbolPronunciationTests that confirms the correct behavior by comparing speech output when the new setting is on/off.

I also tested manually by reading the following text with "Ignore blank lines for line indentation reporting" turned off and on. In either case make sure to have line indentation reporting switched on. To quickly find the new setting, open document formatting settings with NVDA + Shift + D and press Alt + I to get to "line indentation reporting", then press tab to get to "Ignore blank lines for line indentation reporting". Alternatively, you can press alt + B twice.

Test text:

def foo():
	x = 42

	return x

def bar():

With current NVDA or with this change and "Ignore blank lines for line indentation reporting" turned off, the text should report 4 indentation changes like:

def foo():
tab x = 42
no indent blank
tab return x
no indent blank
def bar():

With "Ignore blank lines for line indentation reporting" turned on, it should instead report just 2 indentation changes like:

def foo():
tab x = 42
blank
return x

no indent def bar():

Known issues with pull request:

None that I am aware of.

Change log entries:

New features

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

@SamKacer SamKacer requested review from a team as code owners June 26, 2023 20:17
@SamKacer SamKacer marked this pull request as draft June 26, 2023 20:18
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 85bf451aa5

@XLTechie

XLTechie commented Jun 26, 2023

Copy link
Copy Markdown
Collaborator

Please add an accelerator key for this checkbox. I suggest Alt+b.

Also, would an unassigned gesture to toggle it be useful?

@brunoprietog

Copy link
Copy Markdown

Nice! I hope this will be merged into NVDA. Just a question, instead of the indentation read change occurring on the last line, will it be possible to have NVDA say something like this?

def foo():
tab x = 42
blank
return x
no indent blank
def bar():

That makes a lot more sense to me. Thanks for bringing this to NVDA!

@XLTechie

Copy link
Copy Markdown
Collaborator

In testing this build, it performs in every way as I would expect.

  • Tested with tones and speech (same).
  • Tested switching to an editor window while on a line with an indent in that editor window.
  • Tested changing to a window while on an indented line, at the same indent level as the window I departed.
  • Tested moving to an indented line from a blank line, immediately after switching windows.

While I haven't reviewed the code, the behavior is good IMO, and a useful feature to have.

@XLTechie

Copy link
Copy Markdown
Collaborator

@brunoprietog How would it know which blanks were safe to ignore, and which blanks to reset on? I agree that your wish would make it a more useful feature, but it seems impossible to implement.

That said, if it were a combobox with options of:

  • Speak normally (default)
  • Ignore
  • Ignore only one line

Then that third option could turn something like:

def foo():
	x = 42
	return x


def bar():
	pass

Into:

def foo():
tab  x = 42
return x
blank
no indent blank
def bar():
tab  pass

Which is more Pythonic (consistent with pep-8) for top-level functions anyway, though won't help you with methods.

@brunoprietog

Copy link
Copy Markdown

It's difficult. What occurs to me is that as the user listens to the lines, NVDA checks what is the indentation level of the next line that is not blank in the direction the user navigated (up or down).

If the user presses the up or down arrow, NVDA should check the indentation level of the next line that is not blank, in the direction in which the user navigated (up or down).

  • If the indentation level is lower than the current one, on the next blank line NVDA should immediately report the indentation level change, showing that it is now lower, even if it is on a blank line.
  • If the indentation level is higher than the current one, NVDA should notify the user of the indentation change to the higher level when the user reaches that line.

Here is an example:

def foo
	pass



def bar
	pass

def baz


	pass

Reading it from top to bottom, NVDA should say this:

def foo
tab pass
no indent blank
blank
blank
def bar
tab pass
no indent blank
def baz
blank
blank
tab pass

Reading it from the bottom up, NVDA should say this:

tab pass
no indent blank
blank
def baz
blank
tab pass
no indent def bar
blank
blank
blank
tab pass
no indent def foo

That's more intuitive for me, at least in my case

@cary-rowen

Copy link
Copy Markdown
Contributor

Hi @SamKacer

This is a nice change and I like it.
I believe this will be beneficial to all, Whether this option can be checked by default.

Thanks

@XLTechie

XLTechie commented Jun 27, 2023 via email

Copy link
Copy Markdown
Collaborator

@LeonarddeR

Copy link
Copy Markdown
Collaborator

How ought this to behave when indentation reporting with tones is on?

@SamKacer

SamKacer commented Jun 27, 2023

Copy link
Copy Markdown
Contributor Author

@XLTechie wrote

Please add an accelerator key for this checkbox. I suggest Alt+b.

Also, would an unassigned gesture to toggle it be useful?

Thanks, will do those when I have time. This is my first time adding any new config property, so please let me know about anything I missed. Actually, how do I add the accelerator key? I haven't noticed that when making my changes. Also in which file are the commands for toggling setting properties defined?

to do:

  • add accelerator key for new setting
  • add unassigned toggle command for new setting

@XLTechie

XLTechie commented Jun 27, 2023 via email

Copy link
Copy Markdown
Collaborator

@XLTechie

XLTechie commented Jun 27, 2023 via email

Copy link
Copy Markdown
Collaborator

@SamKacer

Copy link
Copy Markdown
Contributor Author

In regards to @brunoprietog request. He has already asked this in #13394 and I gave a very long reply there in this comment. Linking in case someone wants full context.

Thanks for the suggestion, but this would require a significant overhaul of the indentation reporting code. I am not entirely sure if I would even prefer that behavior. I think I might prefer if the rules for indentation reporting are kept simpler without special cases like this. In any case, I'm not sure the amount of effort to implement would be that worth it.

@SamKacer

Copy link
Copy Markdown
Contributor Author

How ought this to behave when indentation reporting with tones is on?

@LeonarddeR the behavior should be the same whether you are using tones or speech

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 2274421602

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 14abbf5d78

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 7b637323a4

@SamKacer SamKacer marked this pull request as ready for review June 30, 2023 18:43
@SamKacer

Copy link
Copy Markdown
Contributor Author

Ok, this is officially ready for review.

I implemented the 2 features @XLTechie suggested. I added a system test. I fixed all the Flake8 issues. The summary is up to date.

Please let me know if anything else is missing or if anything could be improved. Thanks

@seanbudd seanbudd requested a review from michaelDCurran July 3, 2023 23:40
Comment thread source/speech/speech.py
Comment thread source/speech/speech.py Outdated
Comment thread user_docs/en/userGuide.t2t
Comment thread tests/system/robot/symbolPronunciationTests.py Outdated
Comment thread source/globalCommands.py
Comment thread tests/system/robot/symbolPronunciationTests.py Outdated
@seanbudd seanbudd marked this pull request as draft July 6, 2023 05:46
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit acdc8d32b4

@SamKacer SamKacer force-pushed the ignoreBlankLinesForReportLineIndentation branch from e6744be to 41d2c3c Compare July 6, 2023 16:31
@seanbudd seanbudd marked this pull request as ready for review July 18, 2023 01:13
@seanbudd seanbudd added the merge-early Merge Early in a developer cycle label Jul 21, 2023
@seanbudd seanbudd added this to the 2023.3 milestone Jul 21, 2023

@Qchristensen Qchristensen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User guide reads well, thanks!

@seanbudd seanbudd merged commit 78628be into nvaccess:master Jul 24, 2023
seanbudd pushed a commit that referenced this pull request Sep 22, 2023
Follow-up of #15057

Summary of the issue:
In the GUI, the recent trend is to disable (grey out) the options that are not applicable due to the values of other options.
New option "Ignore blank lines for line indentation reporting" has no sense when report indentation is OFF. Thus it should be greyed out when report indent is off.

This is especially needed to reduce the number of tab presses when navigating in the Doc formatting settings dialog which contains a lot of items.

Description of user facing changes
Option "Ignore blank lines for lineis greyed out when report indent is off and enabled when other indent reporting types are configured.

While at it, in this PR, I have also changed the context help target for "Ignore blank lines" option. Before it was jumping by default to "Document formatting settings" paragraph; now it jumps to "Line indentation reporting" paragraph, which contains more precise information on this topic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-early Merge Early in a developer cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to not announce indentation change for blank lines to Document Formatting Settings

9 participants