Fix smart quote issue (#874)

This commit is contained in:
Veronica Berglyd Olsen
2021-08-30 23:23:47 +02:00
parent 62344376d7
commit bdef9a3955
4 changed files with 61 additions and 11 deletions
+10 -2
View File
@@ -1763,7 +1763,7 @@ class GuiDocEditor(QTextEdit):
nDelete = 0 nDelete = 0
tInsert = theOne tInsert = theOne
if self.mainConf.doReplaceDQuote and theTwo == ' "': if self.mainConf.doReplaceDQuote and theTwo[:1].isspace() and theTwo.endswith('"'):
nDelete = 1 nDelete = 1
tInsert = self._typDQOpen tInsert = self._typDQOpen
@@ -1771,10 +1771,14 @@ class GuiDocEditor(QTextEdit):
nDelete = 1 nDelete = 1
if thePos == 1: if thePos == 1:
tInsert = self._typDQOpen tInsert = self._typDQOpen
elif thePos == 2 and theTwo == '>"':
tInsert = self._typDQOpen
elif thePos == 3 and theThree == '>>"':
tInsert = self._typDQOpen
else: else:
tInsert = self._typDQClose tInsert = self._typDQClose
elif self.mainConf.doReplaceSQuote and theTwo == " '": elif self.mainConf.doReplaceSQuote and theTwo[:1].isspace() and theTwo.endswith("'"):
nDelete = 1 nDelete = 1
tInsert = self._typSQOpen tInsert = self._typSQOpen
@@ -1782,6 +1786,10 @@ class GuiDocEditor(QTextEdit):
nDelete = 1 nDelete = 1
if thePos == 1: if thePos == 1:
tInsert = self._typSQOpen tInsert = self._typSQOpen
elif thePos == 2 and theTwo == ">'":
tInsert = self._typSQOpen
elif thePos == 3 and theThree == ">>'":
tInsert = self._typSQOpen
else: else:
tInsert = self._typSQClose tInsert = self._typSQClose
@@ -27,3 +27,15 @@ This is another paragraph of much longer nonsense text. It is in fact 1 very ver
Full line single quoted text. Full line single quoted text.
“Tab-indented text”
>“Paragraph-indented text”
>>“Right-aligned text”
Tab-indented text
>Paragraph-indented text
>>Right-aligned text
@@ -1,11 +1,11 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="1.2a0" hexVersion="0x010200a0" fileVersion="1.2" timeStamp="2021-01-29 01:10:23"> <novelWriterXML appVersion="1.4.1" hexVersion="0x010401f0" fileVersion="1.2" timeStamp="2021-08-30 23:21:21">
<project> <project>
<name>New Project</name> <name>New Project</name>
<title></title> <title></title>
<saveCount>4</saveCount> <saveCount>5</saveCount>
<autoCount>2</autoCount> <autoCount>2</autoCount>
<editTime>8</editTime> <editTime>5</editTime>
</project> </project>
<settings> <settings>
<doBackup>True</doBackup> <doBackup>True</doBackup>
@@ -15,8 +15,8 @@
<autoOutline>True</autoOutline> <autoOutline>True</autoOutline>
<lastEdited>0e17daca5f3e1</lastEdited> <lastEdited>0e17daca5f3e1</lastEdited>
<lastViewed>None</lastViewed> <lastViewed>None</lastViewed>
<lastWordCount>114</lastWordCount> <lastWordCount>126</lastWordCount>
<novelWordCount>87</novelWordCount> <novelWordCount>99</novelWordCount>
<notesWordCount>27</notesWordCount> <notesWordCount>27</notesWordCount>
<autoReplace/> <autoReplace/>
<titleFormat> <titleFormat>
@@ -85,10 +85,10 @@
<status>New</status> <status>New</status>
<exported>True</exported> <exported>True</exported>
<layout>BOOK</layout> <layout>BOOK</layout>
<charCount>482</charCount> <charCount>612</charCount>
<wordCount>83</wordCount> <wordCount>95</wordCount>
<paraCount>4</paraCount> <paraCount>10</paraCount>
<cursorPos>620</cursorPos> <cursorPos>768</cursorPos>
</item> </item>
<item handle="44cb730c42048" order="1" parent="None"> <item handle="44cb730c42048" order="1" parent="None">
<name>Plot</name> <name>Plot</name>
+30
View File
@@ -286,6 +286,36 @@ 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)
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay) qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
for c in "\t\"Tab-indented text\"":
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 ">\"Paragraph-indented text\"":
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 ">>\"Right-aligned text\"":
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 "\t'Tab-indented text'":
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 ">'Paragraph-indented text'":
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 ">>'Right-aligned text'":
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)
qtbot.wait(stepDelay) qtbot.wait(stepDelay)
nwGUI.docEditor.wCounter.run() nwGUI.docEditor.wCounter.run()
qtbot.wait(stepDelay) qtbot.wait(stepDelay)