Include apostrophes when auto selecting in editor (#1624)
This commit is contained in:
@@ -349,6 +349,9 @@ class nwUnicode:
|
|||||||
# Unicode Constants
|
# Unicode Constants
|
||||||
# =================
|
# =================
|
||||||
|
|
||||||
|
# Lookup
|
||||||
|
APOS_TYPE = "\u0027\u2019\u02bc"
|
||||||
|
|
||||||
# Quotation Marks
|
# Quotation Marks
|
||||||
U_QUOT = "\u0022" # Quotation mark
|
U_QUOT = "\u0022" # Quotation mark
|
||||||
U_APOS = "\u0027" # Apostrophe
|
U_APOS = "\u0027" # Apostrophe
|
||||||
|
|||||||
@@ -2012,20 +2012,25 @@ class GuiDocEditor(QPlainTextEdit):
|
|||||||
cPos = cursor.position()
|
cPos = cursor.position()
|
||||||
bPos = cursor.block().position()
|
bPos = cursor.block().position()
|
||||||
bLen = cursor.block().length()
|
bLen = cursor.block().length()
|
||||||
|
apos = nwUnicode.APOS_TYPE
|
||||||
|
|
||||||
# Scan backwards
|
# Scan backward
|
||||||
sPos = cPos
|
sPos = cPos
|
||||||
for i in range(cPos - bPos):
|
for i in range(cPos - bPos):
|
||||||
sPos = cPos - i - 1
|
sPos = cPos - i - 1
|
||||||
if not self._qDocument.characterAt(sPos).isalnum():
|
cOne = self._qDocument.characterAt(sPos)
|
||||||
|
cTwo = self._qDocument.characterAt(sPos - 1)
|
||||||
|
if not (cOne.isalnum() or cOne in apos and cTwo.isalnum()):
|
||||||
sPos += 1
|
sPos += 1
|
||||||
break
|
break
|
||||||
|
|
||||||
# Scan forwards
|
# Scan forward
|
||||||
ePos = cPos
|
ePos = cPos
|
||||||
for i in range(bPos + bLen - cPos):
|
for i in range(bPos + bLen - cPos):
|
||||||
ePos = cPos + i
|
ePos = cPos + i
|
||||||
if not self._qDocument.characterAt(ePos).isalnum():
|
cOne = self._qDocument.characterAt(ePos)
|
||||||
|
cTwo = self._qDocument.characterAt(ePos + 1)
|
||||||
|
if not (cOne.isalnum() or cOne in apos and cTwo.isalnum()):
|
||||||
break
|
break
|
||||||
|
|
||||||
if ePos - sPos <= 0:
|
if ePos - sPos <= 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user