Generalise space character detection in quote auto-replace
This commit is contained in:
@@ -2334,11 +2334,11 @@ class TextAutoReplace:
|
||||
t3 = text[-3:]
|
||||
t4 = text[-4:]
|
||||
|
||||
leading = t2[:1].isspace()
|
||||
if self._replaceDQuote and t1 == '"':
|
||||
# Process Double Quote
|
||||
if pos == 1:
|
||||
return 1, self._quoteDO
|
||||
elif leading and t2.endswith('"'):
|
||||
elif t2[:1].isspace() and t2.endswith('"'):
|
||||
return 1, self._quoteDO
|
||||
elif pos == 2 and t2 == '>"':
|
||||
return 1, self._quoteDO
|
||||
@@ -2346,19 +2346,20 @@ class TextAutoReplace:
|
||||
return 1, self._quoteDO
|
||||
elif pos == 2 and t2 == '_"':
|
||||
return 1, self._quoteDO
|
||||
elif t3 == ' _"':
|
||||
elif t3[:1].isspace() and t3.endswith('_"'):
|
||||
return 1, self._quoteDO
|
||||
elif pos == 3 and t3 in ('**"', '=="', '~~"'):
|
||||
return 1, self._quoteDO
|
||||
elif t4 in (' **"', ' =="', ' ~~"'):
|
||||
elif t4[:1].isspace() and t4.endswith(('**"', '=="', '~~"')):
|
||||
return 1, self._quoteDO
|
||||
else:
|
||||
return 1, self._quoteDC
|
||||
|
||||
if self._replaceSQuote and t1 == "'":
|
||||
# Process Single Quote
|
||||
if pos == 1:
|
||||
return 1, self._quoteSO
|
||||
elif leading and t2.endswith("'"):
|
||||
elif t2[:1].isspace() and t2.endswith("'"):
|
||||
return 1, self._quoteSO
|
||||
elif pos == 2 and t2 == ">'":
|
||||
return 1, self._quoteSO
|
||||
@@ -2366,16 +2367,17 @@ class TextAutoReplace:
|
||||
return 1, self._quoteSO
|
||||
elif pos == 2 and t2 == "_'":
|
||||
return 1, self._quoteSO
|
||||
elif t3 == " _'":
|
||||
elif t3[:1].isspace() and t3.endswith("_'"):
|
||||
return 1, self._quoteSO
|
||||
elif pos == 3 and t3 in ("**'", "=='", "~~'"):
|
||||
return 1, self._quoteSO
|
||||
elif t4 in (" **'", " =='", " ~~'"):
|
||||
elif t4[:1].isspace() and t4.endswith(("**'", "=='", "~~'")):
|
||||
return 1, self._quoteSO
|
||||
else:
|
||||
return 1, self._quoteSC
|
||||
|
||||
if self._replaceDash and t1 == "-":
|
||||
# Process Dashes
|
||||
if t4 == "----":
|
||||
return 4, "\u2015" # Horizontal bar
|
||||
elif t3 == "---":
|
||||
@@ -2388,6 +2390,7 @@ class TextAutoReplace:
|
||||
return 2, "\u2015" # Horizontal bar
|
||||
|
||||
if self._replaceDots and t3 == "...":
|
||||
# Process Dots
|
||||
return 3, "\u2026" # Ellipsis
|
||||
|
||||
if t1 == "\u2028": # Line separator
|
||||
|
||||
@@ -2370,12 +2370,16 @@ def testGuiEditor_TextAutoReplaceSymbols():
|
||||
assert ar._determine(*prep('>>"')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep('_"')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep(' _"')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep('\u00a0_"')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep('**"')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep(' **"')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep('\u00a0**"')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep('=="')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep(' =="')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep('\u00a0=="')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep('~~"')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep(' ~~"')) == (1, nwUnicode.U_LDQUO)
|
||||
assert ar._determine(*prep('\u00a0~~"')) == (1, nwUnicode.U_LDQUO)
|
||||
|
||||
# Double Quote Close
|
||||
assert ar._determine(*prep('Stuff"')) == (1, nwUnicode.U_RDQUO)
|
||||
@@ -2387,12 +2391,16 @@ def testGuiEditor_TextAutoReplaceSymbols():
|
||||
assert ar._determine(*prep(">>'")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep("_'")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep(" _'")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep("\u00a0_'")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep("**'")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep(" **'")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep("\u00a0**'")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep("=='")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep(" =='")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep("\u00a0=='")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep("~~'")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep(" ~~'")) == (1, nwUnicode.U_LSQUO)
|
||||
assert ar._determine(*prep("\u00a0~~'")) == (1, nwUnicode.U_LSQUO)
|
||||
|
||||
# Single Quote Close
|
||||
assert ar._determine(*prep("Stuff'")) == (1, nwUnicode.U_RSQUO)
|
||||
|
||||
Reference in New Issue
Block a user