Skip to content

Commit

Permalink
Fix most problems regarding issue olivierkes#1065
Browse files Browse the repository at this point in the history
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
  • Loading branch information
TheJackiMonster committed Jan 30, 2023
1 parent 414cd0f commit 380354b
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ def clearHandler(_widget, previous_on_focus_out_event):
def _highlightTextEditSearchResult(self, textEdit, startPos, endPos, clearOnFocusOut):
# On focus out, clear text edit selection.
oldTextCursor = textEdit.textCursor()
if clearOnFocusOut:
self.generateClearHandler(textEdit, lambda widget: widget.setTextCursor(oldTextCursor))

# Highlight search result on the text edit.
c = textEdit.textCursor()
c.setPosition(startPos)
c.setPosition(endPos, QTextCursor.KeepAnchor)

if clearOnFocusOut:
def clearSelection(widget):
cur = widget.textCursor()
if cur.hasSelection() and cur.anchor() == startPos and cur.position() == endPos:
widget.setTextCursor(oldTextCursor)

self.generateClearHandler(textEdit, clearSelection)

# Highlight search result on the text edit.
textEdit.setTextCursor(c)

def _highlightLineEditSearchResult(self, lineEdit, startPos, endPos, clearOnFocusOut):
Expand Down

0 comments on commit 380354b

Please sign in to comment.