Merge pull request #372 from vkbo/issue_371
Bugfix: RegEx Search/Replace Crash
This commit is contained in:
+14
-4
@@ -1202,7 +1202,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
if self.docSearch.isWholeWord:
|
if self.docSearch.isWholeWord:
|
||||||
findOpt |= QTextDocument.FindWholeWords
|
findOpt |= QTextDocument.FindWholeWords
|
||||||
|
|
||||||
searchFor = self.docSearch.getSearchText()
|
searchFor = self.docSearch.getSearchObject()
|
||||||
wasFound = self.find(searchFor, findOpt)
|
wasFound = self.find(searchFor, findOpt)
|
||||||
if not wasFound:
|
if not wasFound:
|
||||||
if self.docSearch.doNextFile and not isBackward:
|
if self.docSearch.doNextFile and not isBackward:
|
||||||
@@ -1230,15 +1230,21 @@ class GuiDocEditor(QTextEdit):
|
|||||||
|
|
||||||
theCursor = self.textCursor()
|
theCursor = self.textCursor()
|
||||||
if not theCursor.hasSelection():
|
if not theCursor.hasSelection():
|
||||||
|
self._findNext()
|
||||||
return
|
return
|
||||||
|
|
||||||
searchFor = self.docSearch.getSearchText()
|
searchFor = self.docSearch.getSearchText()
|
||||||
replWith = self.docSearch.getReplaceText()
|
replWith = self.docSearch.getReplaceText()
|
||||||
selText = theCursor.selectedText()
|
selText = theCursor.selectedText()
|
||||||
|
|
||||||
|
if searchFor.strip() == "":
|
||||||
|
return
|
||||||
|
|
||||||
if self.docSearch.doMatchCap:
|
if self.docSearch.doMatchCap:
|
||||||
replWith = transferCase(selText, replWith)
|
replWith = transferCase(selText, replWith)
|
||||||
|
|
||||||
|
# Double check that we have a real match in case this is called
|
||||||
|
# on a regular word selection and not on a search match
|
||||||
if not self.docSearch.isCaseSense:
|
if not self.docSearch.isCaseSense:
|
||||||
isMatch = searchFor.lower() == selText.lower()
|
isMatch = searchFor.lower() == selText.lower()
|
||||||
else:
|
else:
|
||||||
@@ -1255,8 +1261,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
searchFor, replWith, theCursor.blockNumber()
|
searchFor, replWith, theCursor.blockNumber()
|
||||||
))
|
))
|
||||||
|
|
||||||
if searchFor:
|
self._findNext()
|
||||||
self._findNext()
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1540,7 +1545,7 @@ class GuiDocEditSearch(QFrame):
|
|||||||
self.replaceBox.setText(theText)
|
self.replaceBox.setText(theText)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getSearchText(self):
|
def getSearchObject(self):
|
||||||
"""Return the current search text either as text or as a regular
|
"""Return the current search text either as text or as a regular
|
||||||
expression object.
|
expression object.
|
||||||
"""
|
"""
|
||||||
@@ -1568,6 +1573,11 @@ class GuiDocEditSearch(QFrame):
|
|||||||
|
|
||||||
return theText
|
return theText
|
||||||
|
|
||||||
|
def getSearchText(self):
|
||||||
|
"""Return the current search text.
|
||||||
|
"""
|
||||||
|
return self.searchBox.text()
|
||||||
|
|
||||||
def getReplaceText(self):
|
def getReplaceText(self):
|
||||||
"""Return the current replace text.
|
"""Return the current replace text.
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user