fix crash when double clicking behind the last char
This commit is contained in:
@@ -312,10 +312,10 @@ class InnerBigText(QWidget):
|
|||||||
char_in_line = line.column_to_char(column_in_line)
|
char_in_line = line.column_to_char(column_in_line)
|
||||||
# print("%s in line %s" % (char_in_line, line_number))
|
# print("%s in line %s" % (char_in_line, line_number))
|
||||||
byte_in_line = line.char_index_to_byte(char_in_line)
|
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))
|
# print("%s + %s = %s" % (line.byte_offset(), char_in_line, current_byte))
|
||||||
else:
|
else:
|
||||||
current_byte = self.model.byte_count()
|
current_byte = self.model.byte_count() - 1
|
||||||
return current_byte
|
return current_byte
|
||||||
|
|
||||||
def _has_selection(self):
|
def _has_selection(self):
|
||||||
|
|||||||
@@ -81,12 +81,11 @@ class LogFileModel:
|
|||||||
if len(lines) == 0:
|
if len(lines) == 0:
|
||||||
return "", -1, -1
|
return "", -1, -1
|
||||||
line: Line = lines[0]
|
line: Line = lines[0]
|
||||||
if not lines[0].includes_byte(byte_offset):
|
if not line.includes_byte(byte_offset):
|
||||||
return "", -1, -1
|
return "", -1, -1
|
||||||
|
|
||||||
offset_in_line = byte_offset - line.byte_offset()
|
offset_in_line = byte_offset - line.byte_offset()
|
||||||
char_index = line.byte_index_to_char_index(offset_in_line)
|
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]
|
current_char = line.line()[char_index]
|
||||||
if not self._is_word_char(current_char):
|
if not self._is_word_char(current_char):
|
||||||
return current_char, byte_offset, byte_offset + 1
|
return current_char, byte_offset, byte_offset + 1
|
||||||
|
|||||||
Reference in New Issue
Block a user