diff --git a/logFileModel.py b/logFileModel.py index bb142b1..5ed6248 100644 --- a/logFileModel.py +++ b/logFileModel.py @@ -88,18 +88,18 @@ class LogFileModel: current_char = line.line()[line.byte_index_to_char_index(offset_in_line)] if not self._is_word_char(current_char): return (current_char, byte_offset, byte_offset + 1) - start_in_line = byte_offset - line.byte_offset() + start_in_line = line.byte_index_to_char_index(byte_offset - line.byte_offset()) while start_in_line - 1 >= 0 and self._is_word_char(line.line()[start_in_line - 1]): start_in_line = start_in_line - 1 - end_in_line = byte_offset - line.byte_offset() + end_in_line = line.byte_index_to_char_index(byte_offset - line.byte_offset()) while end_in_line < len(line.line()) and self._is_word_char(line.line()[end_in_line]): end_in_line = end_in_line + 1 - start_byte = start_in_line + line.byte_offset() - end_byte = end_in_line + line.byte_offset() + start_byte = line.char_index_to_byte(start_in_line) + line.byte_offset() + end_byte = line.char_index_to_byte(end_in_line) + line.byte_offset() return (line.line()[start_in_line:end_in_line], start_byte, end_byte) def _is_word_char(self, char: str) -> bool: - return re.match("\w", char) + return re.match(r"\w", char) is not None def data(self, byte_offset: int, scroll_lines: int, lines: int) -> List[Line]: # print("data(%s, %s, %s)" % (byte_offset, scroll_lines, lines))