@@ -76,6 +76,13 @@ class EndSpeech(_enum.Enum):
7676 NONE = None
7777
7878
79+ class ReportLineIndentation (_enum .Enum ):
80+ """Line indentation reporting options. Should match config.configFlags.ReportLineIndentation
81+ """
82+ OFF = 0
83+ SPEECH = 1
84+
85+
7986def _pressKeyAndCollectSpeech (key : str , numberOfTimes : int ) -> _typing .List [str ]:
8087 actual = []
8188 for _ in range (numberOfTimes ):
@@ -500,7 +507,7 @@ def test_symbolInSpeechUI():
500507 _notepad .prepareNotepad ((
501508 "t" # Character doesn't matter, we just want to invoke "Right" speech UI.
502509 ))
503- _setSymbolLevel (SymLevel .ALL )
510+ _setConfig (SymLevel .ALL )
504511 spy = _NvdaLib .getSpyLib ()
505512 expected = "shouldn't sub tick symbol"
506513 spy .override_translationString (EndSpeech .RIGHT .value , expected )
@@ -527,7 +534,7 @@ def test_symbolInSpeechUI():
527534 )
528535
529536 # Show that with symbol level None, the speech UI symbols are not substituted.
530- _setSymbolLevel (SymLevel .NONE )
537+ _setConfig (SymLevel .NONE )
531538 actual = _pressKeyAndCollectSpeech (Move .REVIEW_CHAR .value , numberOfTimes = 1 )
532539 _builtIn .should_be_equal (
533540 actual ,
@@ -536,20 +543,27 @@ def test_symbolInSpeechUI():
536543 )
537544
538545
539- def _setSymbolLevel (symbolLevel : SymLevel ) -> None :
546+ def _setConfig (
547+ symbolLevel : SymLevel ,
548+ reportLineIndentation : ReportLineIndentation = ReportLineIndentation .OFF ,
549+ ignoreBlankLinesForReportLineIndentation : bool = False
550+ ) -> None :
540551 spy = _NvdaLib .getSpyLib ()
541- SYMBOL_LEVEL_KEY = ["speech" , "symbolLevel" ]
542- spy .set_configValue (SYMBOL_LEVEL_KEY , symbolLevel .value )
543- _builtIn .log (message = f"Doing test at symbol level: { symbolLevel } " )
552+ spy .set_configValue (["documentFormatting" , "reportLineIndentation" ], reportLineIndentation .value )
553+ spy .set_configValue (["documentFormatting" , "ignoreBlankLinesForreportLineIndentation" ], ignoreBlankLinesForReportLineIndentation )
554+ spy .set_configValue (["speech" , "symbolLevel" ], symbolLevel .value )
555+ _builtIn .log (message = f"Doing test at symbol level: { symbolLevel } , line indentation reporting: { reportLineIndentation } , ignore blank lines for line indentation reporting: { ignoreBlankLinesForReportLineIndentation } " )
544556
545557
546558def _doTest (
547559 navKey : Move ,
548560 expectedSpeech : _typing .List [str ],
549561 reportedAfterLast : EndSpeech ,
550562 symbolLevel : SymLevel ,
563+ reportLineIndentation : ReportLineIndentation = ReportLineIndentation .OFF ,
564+ ignoreBlankLinesForReportLineIndentation : bool = False
551565) -> None :
552- _setSymbolLevel (symbolLevel )
566+ _setConfig (symbolLevel , reportLineIndentation , ignoreBlankLinesForReportLineIndentation )
553567
554568 actual = _pressKeyAndCollectSpeech (navKey .value , numberOfTimes = len (expectedSpeech ))
555569 _builtIn .should_be_equal (
@@ -600,7 +614,7 @@ def test_tableHeaders():
600614 </table>
601615 """
602616 )
603- _setSymbolLevel (SymLevel .ALL )
617+ _setConfig (SymLevel .ALL )
604618 # Expected to be in browse mode
605619 actualSpeech = _chrome .getSpeechAfterKey ("downArrow" )
606620 _asserts .strings_match (
@@ -669,3 +683,54 @@ def test_tableHeaders():
669683 "Don tick t column 3\n c" , # note symbols ARE replaced in column name
670684 ]
671685 )
686+
687+
688+ def test_ignoreBlankLinesForReportLineIndentation ():
689+ """ Test line indentation reporting with ignoreBlankLinesForReportLineIndentation off and then on
690+ """
691+ _notepad .prepareNotepad ('\n ' .join ([
692+ '' , # blank line
693+ 'def foo' ,
694+ '\t hello' ,
695+ '' , # blank line
696+ '\t world' ,
697+ '' , # blank line
698+ 'def bar'
699+ ]))
700+
701+ def _doTestIgnoreBlankLines (ignoreBlankLines : bool , expectedSpeech : _typing .List [str ]) -> None :
702+ _doTest (
703+ navKey = Move .REVIEW_LINE ,
704+ reportedAfterLast = EndSpeech .BOTTOM ,
705+ symbolLevel = SymLevel .ALL ,
706+ reportLineIndentation = ReportLineIndentation .SPEECH ,
707+ ignoreBlankLinesForReportLineIndentation = ignoreBlankLines ,
708+ expectedSpeech = expectedSpeech
709+ )
710+
711+ _doTestIgnoreBlankLines (
712+ ignoreBlankLines = False ,
713+ expectedSpeech = [
714+ 'def foo' ,
715+ 'tab hello' ,
716+ 'no indent blank' ,
717+ 'tab world' ,
718+ 'no indent blank' ,
719+ 'def bar'
720+ ]
721+ )
722+
723+ _NvdaLib .getSpeechAfterKey (Move .REVIEW_HOME .value ) # reset to start position
724+
725+ _doTestIgnoreBlankLines (
726+ ignoreBlankLines = True ,
727+ expectedSpeech = [
728+ 'def foo' ,
729+ 'tab hello' ,
730+ 'blank' ,
731+ 'world' ,
732+ 'blank' ,
733+ 'no indent def bar'
734+ ]
735+ )
736+
0 commit comments