From 9b5d2b2c2bb70421acd89acd7c01504151ea2434 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 11 Oct 2022 22:26:14 +0200 Subject: [PATCH] Resolve issue #1150 --- novelwriter/gui/doceditor.py | 5 +++++ sample/nwProject.nwx | 8 ++++---- .../guiEditor_Main_Final_000000000000f.nwd | 3 +++ .../guiEditor_Main_Final_nwProject.nwx | 10 +++++----- tests/test_gui/test_gui_guimain.py | 17 ++++++++++++----- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index cfcb8409..0942d823 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -1992,6 +1992,11 @@ class GuiDocEditor(QTextEdit): nDelete = 3 tInsert = nwUnicode.U_HELLIP + elif theOne == nwUnicode.U_LSEP: + # This resolves issue #1150 + nDelete = 1 + tInsert = nwUnicode.U_PSEP + tCheck = tInsert if self.mainConf.fmtPadBefore and tCheck in self.mainConf.fmtPadBefore: if self._allowSpaceBeforeColon(theText, tCheck): diff --git a/sample/nwProject.nwx b/sample/nwProject.nwx index b5bf2647..0cd59b77 100644 --- a/sample/nwProject.nwx +++ b/sample/nwProject.nwx @@ -1,13 +1,13 @@ - + Sample Project Sample Project Jane Smith Jay Doh - 1378 + 1380 236 - 69273 + 69335 False @@ -71,7 +71,7 @@ Chapter One - + Making a Scene diff --git a/tests/reference/guiEditor_Main_Final_000000000000f.nwd b/tests/reference/guiEditor_Main_Final_000000000000f.nwd index ab603231..b45a9dca 100644 --- a/tests/reference/guiEditor_Main_Final_000000000000f.nwd +++ b/tests/reference/guiEditor_Main_Final_000000000000f.nwd @@ -21,6 +21,9 @@ This is a paragraph of nonsense text. +This is another paragraph +with a line separator in it. + This is another paragraph of much longer nonsense text. It is in fact 1 very very NONSENSICAL nonsense text! We can also try replacing “quotes”, even single ‘quotes’ are replaced. Isn’t that nice? We can hyphen-ate, make dashes – and even longer dashes — if we want. Ellipsis? Not a problem either … How about three hyphens — for long dash? It works too. “Full line double quoted text.” diff --git a/tests/reference/guiEditor_Main_Final_nwProject.nwx b/tests/reference/guiEditor_Main_Final_nwProject.nwx index f61d3493..84e7e999 100644 --- a/tests/reference/guiEditor_Main_Final_nwProject.nwx +++ b/tests/reference/guiEditor_Main_Final_nwProject.nwx @@ -1,12 +1,12 @@ - + New Project New Novel Jane Doe 4 2 - 4 + 5 True @@ -17,8 +17,8 @@ None 0000000000008 0000000000008 - 153 - 126 + 163 + 136 27 @@ -59,7 +59,7 @@ New Chapter - + New Scene diff --git a/tests/test_gui/test_gui_guimain.py b/tests/test_gui/test_gui_guimain.py index 76651260..0a569e21 100644 --- a/tests/test_gui/test_gui_guimain.py +++ b/tests/test_gui/test_gui_guimain.py @@ -22,8 +22,8 @@ along with this program. If not, see . import os import pytest -from shutil import copyfile from tools import C, cmpFiles, buildTestProject, XML_IGNORE, writeFile +from shutil import copyfile from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QMessageBox, QInputDialog @@ -31,8 +31,8 @@ from PyQt5.QtWidgets import QMessageBox, QInputDialog from novelwriter.gui import GuiDocEditor, GuiNovelView, GuiOutlineView from novelwriter.enum import nwItemType, nwView, nwWidget from novelwriter.tools import GuiProjectWizard -from novelwriter.gui.projtree import GuiProjectTree from novelwriter.dialogs import GuiEditLabel +from novelwriter.gui.projtree import GuiProjectTree keyDelay = 2 typeDelay = 1 @@ -196,8 +196,6 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock assert cmpFiles(testFile, compFile, ignoreStart=XML_IGNORE) qtbot.wait(stepDelay) - # qtbot.stopForInteraction() - # Re-open project assert nwGUI.openProject(fncProj) qtbot.wait(stepDelay) @@ -372,6 +370,15 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay) qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay) + # Don't allow Shift+Enter to insert a line separator (issue #1150) + for c in "This is another paragraph": + qtbot.keyClick(nwGUI.docEditor, c, delay=typeDelay) + qtbot.keyClick(nwGUI.docEditor, Qt.Key_Enter, modifier=Qt.ShiftModifier, delay=typeDelay) + for c in "with a line separator in it.": + 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) + # Auto-Replace # ============ @@ -540,7 +547,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock copyfile(projFile, testFile) assert cmpFiles(testFile, compFile) - # qtbot.stopForInteraction() + # qtbot.stop() # END Test testGuiMain_Editing