From b3e5d535b7e80c30b7b14e97d3f9ce4f6a58769f Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 26 Nov 2021 18:43:12 +0100 Subject: [PATCH] fix crash when double clicking behind the last char --- bigtext.py | 4 ++-- logFileModel.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bigtext.py b/bigtext.py index 41ed807..cfb61db 100644 --- a/bigtext.py +++ b/bigtext.py @@ -312,10 +312,10 @@ class InnerBigText(QWidget): char_in_line = line.column_to_char(column_in_line) # print("%s in line %s" % (char_in_line, line_number)) byte_in_line = line.char_index_to_byte(char_in_line) - current_byte = line.byte_offset() + byte_in_line + current_byte = line.byte_offset() + byte_in_line - 1 # print("%s + %s = %s" % (line.byte_offset(), char_in_line, current_byte)) else: - current_byte = self.model.byte_count() + current_byte = self.model.byte_count() - 1 return current_byte def _has_selection(self): diff --git a/logFileModel.py b/logFileModel.py index be94cfb..76a2fe5 100644 --- a/logFileModel.py +++ b/logFileModel.py @@ -81,12 +81,11 @@ class LogFileModel: if len(lines) == 0: return "", -1, -1 line: Line = lines[0] - if not lines[0].includes_byte(byte_offset): + if not line.includes_byte(byte_offset): return "", -1, -1 offset_in_line = byte_offset - line.byte_offset() char_index = line.byte_index_to_char_index(offset_in_line) - # todo char_index may be out of range current_char = line.line()[char_index] if not self._is_word_char(current_char): return current_char, byte_offset, byte_offset + 1