Simplify the auto-insert space check code as this is efficient enough
This commit is contained in:
@@ -111,7 +111,6 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self._typSQOpen = "'"
|
self._typSQOpen = "'"
|
||||||
self._typSQClose = "'"
|
self._typSQClose = "'"
|
||||||
self._typPadChar = " "
|
self._typPadChar = " "
|
||||||
self._doSpacePad = False
|
|
||||||
|
|
||||||
# Core Elements and Signals
|
# Core Elements and Signals
|
||||||
qDoc = self.document()
|
qDoc = self.document()
|
||||||
@@ -222,7 +221,6 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self._nonWord += "".join(self.mainConf.fmtSingleQuotes)
|
self._nonWord += "".join(self.mainConf.fmtSingleQuotes)
|
||||||
|
|
||||||
# Typography
|
# Typography
|
||||||
self._doSpacePad = bool(self.mainConf.fmtPadBefore) or bool(self.mainConf.fmtPadAfter)
|
|
||||||
if self.mainConf.fmtPadThin:
|
if self.mainConf.fmtPadThin:
|
||||||
self._typPadChar = nwUnicode.U_THNBSP
|
self._typPadChar = nwUnicode.U_THNBSP
|
||||||
else:
|
else:
|
||||||
@@ -1994,21 +1992,20 @@ class GuiDocEditor(QTextEdit):
|
|||||||
nDelete = 3
|
nDelete = 3
|
||||||
tInsert = nwUnicode.U_HELLIP
|
tInsert = nwUnicode.U_HELLIP
|
||||||
|
|
||||||
if self._doSpacePad:
|
tCheck = tInsert
|
||||||
tCheck = tInsert
|
if self.mainConf.fmtPadBefore and tCheck in self.mainConf.fmtPadBefore:
|
||||||
if tCheck in self.mainConf.fmtPadBefore:
|
if self._allowSpaceBeforeColon(theText, tCheck):
|
||||||
if self._allowSpaceBeforeColon(theText, tCheck):
|
nDelete = max(nDelete, 1)
|
||||||
nDelete = max(nDelete, 1)
|
chkPos = thePos - nDelete - 1
|
||||||
chkPos = thePos - nDelete - 1
|
if chkPos >= 0 and theText[chkPos].isspace():
|
||||||
if chkPos >= 0 and theText[chkPos].isspace():
|
# Strip existing space before inserting a new (#1061)
|
||||||
# Strip existing space before inserting a new (#1061)
|
nDelete += 1
|
||||||
nDelete += 1
|
tInsert = self._typPadChar + tInsert
|
||||||
tInsert = self._typPadChar + tInsert
|
|
||||||
|
|
||||||
if tCheck in self.mainConf.fmtPadAfter:
|
if self.mainConf.fmtPadAfter and tCheck in self.mainConf.fmtPadAfter:
|
||||||
if self._allowSpaceBeforeColon(theText, tCheck):
|
if self._allowSpaceBeforeColon(theText, tCheck):
|
||||||
nDelete = max(nDelete, 1)
|
nDelete = max(nDelete, 1)
|
||||||
tInsert = tInsert + self._typPadChar
|
tInsert = tInsert + self._typPadChar
|
||||||
|
|
||||||
if nDelete > 0:
|
if nDelete > 0:
|
||||||
theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, nDelete)
|
theCursor.movePosition(QTextCursor.Left, QTextCursor.KeepAnchor, nDelete)
|
||||||
|
|||||||
Reference in New Issue
Block a user