Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'highlight_selected_word' method fails in very long texts #1980

Closed
centaurialpha opened this issue Oct 7, 2016 · 2 comments
Closed

The 'highlight_selected_word' method fails in very long texts #1980

centaurialpha opened this issue Oct 7, 2016 · 2 comments
Assignees

Comments

@centaurialpha
Copy link
Member

centaurialpha commented Oct 7, 2016

sssss

@centaurialpha
Copy link
Member Author

centaurialpha commented Oct 7, 2016

I have changed this part of the code:

index = text.find(search)
self.search_lines = []  # Restore search lines
appendLine = self.search_lines.append
while index != -1 and word:
    line = self.SendScintilla(QsciScintilla.SCI_LINEFROMPOSITION,
                                           index)
    if line not in self.search_lines:
        appendLine(line)
        self.SendScintilla(QsciScintilla.SCI_INDICATORFILLRANGE,
                                     index, word_length)
        index = text.find(search, index + 1)

by:

search = re.compile(search)
self.search_lines = []
appendLine = self.search_lines.append
if word:
    for lineno, line_text in enumerate(text.splitlines()):
        for i in search.finditer(line_text):
            start, end = i.start(), i.end()
            self.fillIndicatorRange(lineno, start, lineno, end,
                                                self.__indicator_word)
            if lineno not in self.search_lines:
                appendLine(lineno)

And the results were better, but I do not know if more efficient

@centaurialpha centaurialpha self-assigned this Oct 15, 2016
@centaurialpha
Copy link
Member Author

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant