From f21e85534d78899c4c734ebbdbc8db7459d8ca1a Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Thu, 21 Nov 2019 15:25:48 +0100 Subject: [PATCH] Handle comments with and without an initial space --- nw/gui/elements/doceditor.py | 7 +++++-- nw/guimain.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nw/gui/elements/doceditor.py b/nw/gui/elements/doceditor.py index 1f878898..681f1082 100644 --- a/nw/gui/elements/doceditor.py +++ b/nw/gui/elements/doceditor.py @@ -799,6 +799,9 @@ class GuiDocEditor(QTextEdit): if theText.startswith("@"): logger.error("Cannot apply block format to keyword/value line") return + elif theText.startswith("% "): + newText = theText[2:] + cOffset = 2 elif theText.startswith("%"): newText = theText[1:] cOffset = 1 @@ -820,8 +823,8 @@ class GuiDocEditor(QTextEdit): # Apply new format if docAction == nwDocAction.BLOCK_COM: - theText = "%"+newText - cOffset -= 1 + theText = "% "+newText + cOffset -= 2 elif docAction == nwDocAction.BLOCK_H1: theText = "# "+newText cOffset -= 2 diff --git a/nw/guimain.py b/nw/guimain.py index e07af0bd..54a928e2 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -459,6 +459,9 @@ class GuiMain(QMainWindow): return True def passDocumentAction(self, theAction): + """Pass on document action theAction to whatever document has + the focus. If no document has focus, the action is discarded. + """ if self.docEditor.hasFocus(): self.docEditor.docAction(theAction) elif self.docViewer.hasFocus():