diff --git a/novelwriter/gui/mainmenu.py b/novelwriter/gui/mainmenu.py index 6f91bd05..0465bed5 100644 --- a/novelwriter/gui/mainmenu.py +++ b/novelwriter/gui/mainmenu.py @@ -782,9 +782,9 @@ class GuiMainMenu(QMenuBar): ) # Format > Ignore Text - self.aFmtComment = self.fmtMenu.addAction(self.tr("Toggle Ignore Text")) - self.aFmtComment.setShortcut("Ctrl+Shift+D") - self.aFmtComment.triggered.connect( + self.aFmtIgnore = self.fmtMenu.addAction(self.tr("Toggle Ignore Text")) + self.aFmtIgnore.setShortcut("Ctrl+Shift+D") + self.aFmtIgnore.triggered.connect( lambda: self.requestDocAction.emit(nwDocAction.BLOCK_IGN) ) diff --git a/tests/test_core/test_core_tokenizer.py b/tests/test_core/test_core_tokenizer.py index 56099589..163cd151 100644 --- a/tests/test_core/test_core_tokenizer.py +++ b/tests/test_core/test_core_tokenizer.py @@ -452,6 +452,14 @@ def testCoreToken_MetaFormat(mockGUI): tokens.tokenizeText() assert tokens.allMarkdown[-1] == "% A comment\n\n" + # Ignore Text + tokens._text = "%~ Some text\n" + tokens.tokenizeText() + assert tokens._tokens == [ + (Tokenizer.T_EMPTY, 0, "", [], Tokenizer.A_NONE), + ] + assert tokens.allMarkdown[-1] == "\n" + # Synopsis tokens._text = "%synopsis: The synopsis\n" tokens.tokenizeText() diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index 15b20efb..6c2070fe 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -579,6 +579,11 @@ def testGuiEditor_Actions(qtbot, nwGUI, projPath, ipsumText, mockRnd): assert nwGUI.docEditor.docAction(nwDocAction.BLOCK_COM) is True assert nwGUI.docEditor.getText() == "#### Scene Title\n\n% Scene text.\n\n" + # Ignore Text + nwGUI.docEditor.setCursorPosition(20) + assert nwGUI.docEditor.docAction(nwDocAction.BLOCK_IGN) is True + assert nwGUI.docEditor.getText() == "#### Scene Title\n\n%~ Scene text.\n\n" + # Text nwGUI.docEditor.setCursorPosition(20) assert nwGUI.docEditor.docAction(nwDocAction.BLOCK_TXT) is True @@ -1202,6 +1207,20 @@ def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, projPath, ipsumText assert nwGUI.docEditor.getText() == "Some text\n\n" assert nwGUI.docEditor.getCursorPosition() == 4 + # Toggle Ignore Text w/Space + nwGUI.docEditor.replaceText("%~ Some text\n\n") + nwGUI.docEditor.setCursorPosition(5) + assert nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_IGN) is True + assert nwGUI.docEditor.getText() == "Some text\n\n" + assert nwGUI.docEditor.getCursorPosition() == 2 + + # Toggle Ignore Text wo/Space + nwGUI.docEditor.replaceText("%~Some text\n\n") + nwGUI.docEditor.setCursorPosition(5) + assert nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_IGN) is True + assert nwGUI.docEditor.getText() == "Some text\n\n" + assert nwGUI.docEditor.getCursorPosition() == 3 + # Header 1 nwGUI.docEditor.replaceText("Some text\n\n") nwGUI.docEditor.setCursorPosition(5)