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:
|
||||
findOpt |= QTextDocument.FindWholeWords
|
||||
|
||||
searchFor = self.docSearch.getSearchText()
|
||||
searchFor = self.docSearch.getSearchObject()
|
||||
wasFound = self.find(searchFor, findOpt)
|
||||
if not wasFound:
|
||||
if self.docSearch.doNextFile and not isBackward:
|
||||
@@ -1230,15 +1230,21 @@ class GuiDocEditor(QTextEdit):
|
||||
|
||||
theCursor = self.textCursor()
|
||||
if not theCursor.hasSelection():
|
||||
self._findNext()
|
||||
return
|
||||
|
||||
searchFor = self.docSearch.getSearchText()
|
||||
replWith = self.docSearch.getReplaceText()
|
||||
selText = theCursor.selectedText()
|
||||
|
||||
if searchFor.strip() == "":
|
||||
return
|
||||
|
||||
if self.docSearch.doMatchCap:
|
||||
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:
|
||||
isMatch = searchFor.lower() == selText.lower()
|
||||
else:
|
||||
@@ -1255,8 +1261,7 @@ class GuiDocEditor(QTextEdit):
|
||||
searchFor, replWith, theCursor.blockNumber()
|
||||
))
|
||||
|
||||
if searchFor:
|
||||
self._findNext()
|
||||
self._findNext()
|
||||
|
||||
return
|
||||
|
||||
@@ -1540,7 +1545,7 @@ class GuiDocEditSearch(QFrame):
|
||||
self.replaceBox.setText(theText)
|
||||
return True
|
||||
|
||||
def getSearchText(self):
|
||||
def getSearchObject(self):
|
||||
"""Return the current search text either as text or as a regular
|
||||
expression object.
|
||||
"""
|
||||
@@ -1568,6 +1573,11 @@ class GuiDocEditSearch(QFrame):
|
||||
|
||||
return theText
|
||||
|
||||
def getSearchText(self):
|
||||
"""Return the current search text.
|
||||
"""
|
||||
return self.searchBox.text()
|
||||
|
||||
def getReplaceText(self):
|
||||
"""Return the current replace text.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user