Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Shift+Enter to auto-replace #1151

Merged
merged 1 commit into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions novelwriter/gui/doceditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,11 @@ def _docAutoReplace(self, theBlock):
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):
Expand Down
8 changes: 4 additions & 4 deletions sample/nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="1.7-beta1" hexVersion="0x010700b1" fileVersion="1.4" timeStamp="2022-07-31 18:38:08">
<novelWriterXML appVersion="2.0-beta1" hexVersion="0x020000b1" fileVersion="1.4" timeStamp="2022-10-11 22:07:39">
<project>
<name>Sample Project</name>
<title>Sample Project</title>
<author>Jane Smith</author>
<author>Jay Doh</author>
<saveCount>1378</saveCount>
<saveCount>1380</saveCount>
<autoCount>236</autoCount>
<editTime>69273</editTime>
<editTime>69335</editTime>
</project>
<settings>
<doBackup>False</doBackup>
Expand Down Expand Up @@ -71,7 +71,7 @@
<name status="sf24ce6" import="ia857f0" exported="True">Chapter One</name>
</item>
<item handle="636b6aa9b697b" parent="6a2d6d5f4f401" root="7031beac91f75" order="0" type="FILE" class="NOVEL" layout="DOCUMENT">
<meta expanded="False" charCount="2687" wordCount="479" paraCount="14" cursorPos="2183"/>
<meta expanded="False" charCount="2687" wordCount="479" paraCount="14" cursorPos="67"/>
<name status="s90e6c9" import="ia857f0" exported="True">Making a Scene</name>
</item>
<item handle="bc0cbd2a407f3" parent="6a2d6d5f4f401" root="7031beac91f75" order="1" type="FILE" class="NOVEL" layout="DOCUMENT">
Expand Down
3 changes: 3 additions & 0 deletions tests/reference/guiEditor_Main_Final_000000000000f.nwd
Original file line number Diff line number Diff line change
Expand Up @@ -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.”
Expand Down
10 changes: 5 additions & 5 deletions tests/reference/guiEditor_Main_Final_nwProject.nwx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="1.7-beta1" hexVersion="0x010700b1" fileVersion="1.4" timeStamp="2022-10-01 22:33:13">
<novelWriterXML appVersion="2.0-beta1" hexVersion="0x020000b1" fileVersion="1.4" timeStamp="2022-10-11 22:21:42">
<project>
<name>New Project</name>
<title>New Novel</title>
<author>Jane Doe</author>
<saveCount>4</saveCount>
<autoCount>2</autoCount>
<editTime>4</editTime>
<editTime>5</editTime>
</project>
<settings>
<doBackup>True</doBackup>
Expand All @@ -17,8 +17,8 @@
<lastViewed>None</lastViewed>
<lastNovel>0000000000008</lastNovel>
<lastOutline>0000000000008</lastOutline>
<lastWordCount>153</lastWordCount>
<novelWordCount>126</novelWordCount>
<lastWordCount>163</lastWordCount>
<novelWordCount>136</novelWordCount>
<notesWordCount>27</notesWordCount>
<autoReplace/>
<titleFormat>
Expand Down Expand Up @@ -59,7 +59,7 @@
<name status="s000000" import="i000004" exported="True">New Chapter</name>
</item>
<item handle="000000000000f" parent="000000000000d" root="0000000000008" order="1" type="FILE" class="NOVEL" layout="DOCUMENT">
<meta expanded="False" charCount="728" wordCount="119" paraCount="13" cursorPos="954"/>
<meta expanded="False" charCount="781" wordCount="129" paraCount="14" cursorPos="1010"/>
<name status="s000000" import="i000004" exported="True">New Scene</name>
</item>
<item handle="0000000000009" parent="None" root="0000000000009" order="1" type="ROOT" class="PLOT">
Expand Down
17 changes: 12 additions & 5 deletions tests/test_gui/test_gui_guimain.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
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

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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
# ============

Expand Down Expand Up @@ -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

Expand Down