From e6b27322811d67af6c5dc4e6220747a0ccd15494 Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Thu, 29 Sep 2022 14:11:39 +0200
Subject: [PATCH 1/7] Fix insert spaces crash (#1118)
---
novelwriter/gui/doceditor.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py
index f93fcab4..5521e628 100644
--- a/novelwriter/gui/doceditor.py
+++ b/novelwriter/gui/doceditor.py
@@ -1982,12 +1982,12 @@ class GuiDocEditor(QTextEdit):
tCheck = tInsert
if tCheck in self.mainConf.fmtPadBefore:
- if self.allowSpaceBeforeColon(theText, tCheck):
+ if self._allowSpaceBeforeColon(theText, tCheck):
nDelete = max(nDelete, 1)
tInsert = self._typPadChar + tInsert
if tCheck in self.mainConf.fmtPadAfter:
- if self.allowSpaceBeforeColon(theText, tCheck):
+ if self._allowSpaceBeforeColon(theText, tCheck):
nDelete = max(nDelete, 1)
tInsert = tInsert + self._typPadChar
From 5adf21e87a6b1085dd6f34d927329345ee27d4da Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Thu, 29 Sep 2022 14:25:42 +0200
Subject: [PATCH 2/7] Add integration test coverage of insert spaces issue
---
.../guiEditor_Main_Final_0e17daca5f3e1.nwd | 8 ++++
.../guiEditor_Main_Final_nwProject.nwx | 14 +++----
tests/test_gui/test_gui_guimain.py | 38 +++++++++++++++++++
3 files changed, 53 insertions(+), 7 deletions(-)
diff --git a/tests/reference/guiEditor_Main_Final_0e17daca5f3e1.nwd b/tests/reference/guiEditor_Main_Final_0e17daca5f3e1.nwd
index 67886bc1..aabfe562 100644
--- a/tests/reference/guiEditor_Main_Final_0e17daca5f3e1.nwd
+++ b/tests/reference/guiEditor_Main_Final_0e17daca5f3e1.nwd
@@ -27,6 +27,14 @@ This is another paragraph of much longer nonsense text. It is in fact 1 very ver
‘Full line single quoted text.’
+Some “ double quoted text with spaces padded ”.
+
+@object: NoSpaceAdded
+
+% synopsis: No space before this colon.
+
+Add space before this colon : See?
+
“Tab-indented text”
>“Paragraph-indented text”
diff --git a/tests/reference/guiEditor_Main_Final_nwProject.nwx b/tests/reference/guiEditor_Main_Final_nwProject.nwx
index 1111c579..d4dbfd2e 100644
--- a/tests/reference/guiEditor_Main_Final_nwProject.nwx
+++ b/tests/reference/guiEditor_Main_Final_nwProject.nwx
@@ -1,5 +1,5 @@
-
+
New Project
@@ -15,8 +15,8 @@
True
0e17daca5f3e1
None
- 126
- 99
+ 142
+ 115
27
@@ -85,10 +85,10 @@
New
True
DOCUMENT
- 612
- 95
- 10
- 768
+ 693
+ 111
+ 12
+ 917
-
Plot
diff --git a/tests/test_gui/test_gui_guimain.py b/tests/test_gui/test_gui_guimain.py
index cbc37dc7..4eab5fb0 100644
--- a/tests/test_gui/test_gui_guimain.py
+++ b/tests/test_gui/test_gui_guimain.py
@@ -340,6 +340,9 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir):
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ # Auto-Replace
+ # ============
+
for c in (
"This is another paragraph of much longer nonsense text. "
"It is in fact 1 very very NONSENSICAL nonsense text! "
@@ -373,6 +376,41 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir):
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ # Insert spaces before and after quotes
+ nwGUI.mainConf.fmtPadBefore = "\u201d"
+ nwGUI.mainConf.fmtPadAfter = "\u201c"
+
+ for c in "Some \"double quoted text with spaces padded\".":
+ qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+
+ nwGUI.mainConf.fmtPadBefore = ""
+ nwGUI.mainConf.fmtPadAfter = ""
+
+ # Insert spaces before colon, but ignore tags and synopsis
+ nwGUI.mainConf.fmtPadBefore = ":"
+
+ for c in "@object: NoSpaceAdded":
+ qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+
+ for c in "% synopsis: No space before this colon.":
+ qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+
+ for c in "Add space before this colon: See?":
+ qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+ qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
+
+ nwGUI.mainConf.fmtPadBefore = ""
+
+ # Indent and Align
+ # ================
+
for c in "\t\"Tab-indented text\"":
qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay)
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
From 726749064593ad57f1508586c7188cc2af9d5ce6 Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Thu, 29 Sep 2022 14:33:12 +0200
Subject: [PATCH 3/7] Backport fix #1113
---
novelwriter/gui/doceditor.py | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py
index 5521e628..f2412242 100644
--- a/novelwriter/gui/doceditor.py
+++ b/novelwriter/gui/doceditor.py
@@ -91,6 +91,7 @@ class GuiDocEditor(QTextEdit):
self._spellCheck = False # Flag for spell checking enabled
self._nonWord = "\"'" # Characters to not include in spell checking
+ self._vpMargin = 0 # The editor viewport margin, set during init
# Document Variables
self._charCount = 0 # Character count
@@ -268,10 +269,12 @@ class GuiDocEditor(QTextEdit):
self.docHeader.matchColours()
self.docFooter.matchColours()
- # Set default text margins
- cM = self.mainConf.getTextMargin()
- qDoc.setDocumentMargin(0)
- self.setViewportMargins(cM, cM, cM, cM)
+ # Due to cursor visibility, a part of the margin must be
+ # allocated to the document itself. See issue #1112.
+ cW = self.cursorWidth()
+ qDoc.setDocumentMargin(cW)
+ self._vpMargin = max(self.mainConf.getTextMargin() - cW, 0)
+ self.setViewportMargins(self._vpMargin, self._vpMargin, self._vpMargin, self._vpMargin)
# Also set the document text options for the document text flow
theOpt = QTextOption()
@@ -533,7 +536,6 @@ class GuiDocEditor(QTextEdit):
"""
wW = self.width()
wH = self.height()
- cM = self.mainConf.getTextMargin()
vBar = self.verticalScrollBar()
sW = vBar.width() if vBar.isVisible() else 0
@@ -541,10 +543,10 @@ class GuiDocEditor(QTextEdit):
hBar = self.horizontalScrollBar()
sH = hBar.height() if hBar.isVisible() else 0
- tM = cM
+ tM = self._vpMargin
if self.mainConf.textWidth > 0 or self.theParent.isFocusMode:
tW = self.mainConf.getTextWidth(self.theParent.isFocusMode)
- tM = max((wW - sW - tW)//2, cM)
+ tM = max((wW - sW - tW)//2, self._vpMargin)
tB = self.frameWidth()
tW = wW - 2*tB - sW
@@ -561,8 +563,8 @@ class GuiDocEditor(QTextEdit):
rL = wW - sW - rW - 2*tB
self.docSearch.move(rL, 2*tB)
- uM = max(cM, tH, rH)
- lM = max(cM, fH)
+ uM = max(self._vpMargin, tH, rH)
+ lM = max(self._vpMargin, fH)
self.setViewportMargins(tM, uM, tM, lM)
return
From d82c739f013dde48b7449040e65e841964090569 Mon Sep 17 00:00:00 2001
From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com>
Date: Thu, 29 Sep 2022 19:23:41 +0200
Subject: [PATCH 4/7] Release 1.6.4
---
CHANGELOG.md | 19 +++++++++++++++++++
novelwriter/__init__.py | 6 +++---
novelwriter/assets/text/release_notes.htm | 6 ++++++
sample/nwProject.nwx | 6 +++---
4 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d305d045..6fa9ffed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,24 @@
# novelWriter Changelog
+## Version 1.6.4 [2022-09-29]
+
+### Release Notes
+
+This is a bugfix release that fixes a critical bug in the insert non-breaking spaces feature. It
+basically no longer worked in the 1.6.3 release. This release also fixes a minor issue where the
+text cursor sometimes dissappears when reaching the right-hand edge of the text editor window.
+
+### Detailed Changelog
+
+**Bugfixes**
+
+* Fixed a bug in the auto-replace feature of the editor that caused a crash when using the insert
+ non-breaking spaces feature was used. Issue #1118. PR #1120.
+* Backported a bugfix from 1.7 RC1 that resolves an issue with the text cursor sometimes
+ dissappearing at the right-hand edge of the text editor. Issues #1112 and #1119. PR #1120.
+
+----
+
## Version 1.6.3 [2022-08-18]
### Release Notes
diff --git a/novelwriter/__init__.py b/novelwriter/__init__.py
index 4428de01..2ee812f4 100644
--- a/novelwriter/__init__.py
+++ b/novelwriter/__init__.py
@@ -60,9 +60,9 @@ __license__ = "GPLv3"
__author__ = "Veronica Berglyd Olsen"
__maintainer__ = "Veronica Berglyd Olsen"
__email__ = "code@vkbo.net"
-__version__ = "1.6.3"
-__hexversion__ = "0x010603f0"
-__date__ = "2022-08-18"
+__version__ = "1.6.4"
+__hexversion__ = "0x010604f0"
+__date__ = "2022-09-29"
__status__ = "Stable"
__domain__ = "novelwriter.io"
__url__ = "https://novelwriter.io"
diff --git a/novelwriter/assets/text/release_notes.htm b/novelwriter/assets/text/release_notes.htm
index a66c4368..a57d329c 100644
--- a/novelwriter/assets/text/release_notes.htm
+++ b/novelwriter/assets/text/release_notes.htm
@@ -64,5 +64,11 @@ the slider splitting the editor and viewer panels can no longer be dragged until
disappears. It was not necessarily obvious how the viewer panel could be restored in such cases.
+Patch 1.6.4 – 29 September 2022
+
+This is a bugfix release that fixes a critical bug in the insert non-breaking spaces feature. It
+basically no longer worked in the 1.6.3 release. This release also fixes a minor issue where the
+text cursor sometimes dissappears when reaching the right-hand edge of the text editor window.
+