@@ -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,35 @@ 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 (
554+ ["documentFormatting" , "ignoreBlankLinesForReportLineIndentation" ],
555+ ignoreBlankLinesForReportLineIndentation
556+ )
557+ spy .set_configValue (["speech" , "symbolLevel" ], symbolLevel .value )
558+ message = (
559+ f"Doing test at symbol level: { symbolLevel } "
560+ f", line indentation reporting: { reportLineIndentation } "
561+ f", ignore blank lines for line indentation reporting: { ignoreBlankLinesForReportLineIndentation } "
562+ )
563+ _builtIn .log (message = message )
544564
545565
546566def _doTest (
547567 navKey : Move ,
548568 expectedSpeech : _typing .List [str ],
549569 reportedAfterLast : EndSpeech ,
550570 symbolLevel : SymLevel ,
571+ reportLineIndentation : ReportLineIndentation = ReportLineIndentation .OFF ,
572+ ignoreBlankLinesForReportLineIndentation : bool = False
551573) -> None :
552- _setSymbolLevel (symbolLevel )
574+ _setConfig (symbolLevel , reportLineIndentation , ignoreBlankLinesForReportLineIndentation )
553575
554576 actual = _pressKeyAndCollectSpeech (navKey .value , numberOfTimes = len (expectedSpeech ))
555577 _builtIn .should_be_equal (
@@ -600,7 +622,7 @@ def test_tableHeaders():
600622 </table>
601623 """
602624 )
603- _setSymbolLevel (SymLevel .ALL )
625+ _setConfig (SymLevel .ALL )
604626 # Expected to be in browse mode
605627 actualSpeech = _chrome .getSpeechAfterKey ("downArrow" )
606628 _asserts .strings_match (
@@ -669,3 +691,54 @@ def test_tableHeaders():
669691 "Don tick t column 3\n c" , # note symbols ARE replaced in column name
670692 ]
671693 )
694+
695+
696+ def test_ignoreBlankLinesForReportLineIndentation ():
697+ """ Test line indentation reporting with ignoreBlankLinesForReportLineIndentation off and then on
698+ """
699+ _notepad .prepareNotepad ('\n ' .join ([
700+ '' , # blank line
701+ 'def foo' ,
702+ '\t hello' ,
703+ '' , # blank line
704+ '\t world' ,
705+ '' , # blank line
706+ 'def bar'
707+ ]))
708+
709+ def _doTestIgnoreBlankLines (ignoreBlankLines : bool , expectedSpeech : _typing .List [str ]) -> None :
710+ _doTest (
711+ navKey = Move .REVIEW_LINE ,
712+ reportedAfterLast = EndSpeech .BOTTOM ,
713+ symbolLevel = SymLevel .ALL ,
714+ reportLineIndentation = ReportLineIndentation .SPEECH ,
715+ ignoreBlankLinesForReportLineIndentation = ignoreBlankLines ,
716+ expectedSpeech = expectedSpeech
717+ )
718+
719+ _doTestIgnoreBlankLines (
720+ ignoreBlankLines = False ,
721+ expectedSpeech = [
722+ 'def foo' ,
723+ 'tab hello' ,
724+ 'no indent blank' ,
725+ 'tab world' ,
726+ 'no indent blank' ,
727+ 'def bar'
728+ ]
729+ )
730+
731+ _NvdaLib .getSpeechAfterKey (Move .REVIEW_HOME .value ) # reset to start position
732+
733+ _doTestIgnoreBlankLines (
734+ ignoreBlankLines = True ,
735+ expectedSpeech = [
736+ 'def foo' ,
737+ 'tab hello' ,
738+ 'blank' ,
739+ 'world' ,
740+ 'blank' ,
741+ 'no indent def bar'
742+ ]
743+ )
744+
0 commit comments