Skip to content

Commit

Permalink
Fixed crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Aug 7, 2024
1 parent 571cea4 commit 6775acf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ui/widget_builder_text_document.nim
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ proc createTextLines(self: TextDocumentEditor, builder: UINodeBuilder, app: App,
if partIndex.getSome(partIndex):
let styledLine = self.getStyledText(line)
let (startRune, _) = styledLine.getTextRange(partIndex)
if partIndex notin 0..<styledLine.parts.len:
return

let part = styledLine.parts[partIndex]
let isInlay = part.textRange.isNone
let offset = self.getCursorPos(builder, part.text, line, startRune, if isInlay: vec2() else: pos)
Expand Down Expand Up @@ -562,6 +565,9 @@ proc createTextLines(self: TextDocumentEditor, builder: UINodeBuilder, app: App,
let newCursor = if partIndex.getSome(partIndex):
let styledLine = self.getStyledText(line)
let (startRune, _) = styledLine.getTextRange(partIndex)
if partIndex notin 0..<styledLine.parts.len:
return

let part = styledLine.parts[partIndex]
let isInlay = part.textRange.isNone
let offset = self.getCursorPos(builder, part.text, line, startRune, if isInlay: vec2() else: pos)
Expand All @@ -585,6 +591,9 @@ proc createTextLines(self: TextDocumentEditor, builder: UINodeBuilder, app: App,

let styledLine = self.getStyledText(line)
let (startRune, _) = styledLine.getTextRange(partIndex)
if partIndex notin 0..<styledLine.parts.len:
return

let part = styledLine.parts[partIndex]
let offset = self.getCursorPos(builder, part.text, line, startRune, pos)
self.lastHoverLocationBounds = node.boundsAbsolute.some
Expand All @@ -596,6 +605,9 @@ proc createTextLines(self: TextDocumentEditor, builder: UINodeBuilder, app: App,

let styledLine = self.getStyledText(line)
let (startRune, _) = styledLine.getTextRange(partIndex)
if partIndex notin 0..<styledLine.parts.len:
return

let part = styledLine.parts[partIndex]
let offset = self.getCursorPos(builder, part.text, line, startRune, pos)
self.lastHoverLocationBounds = node.boundsAbsolute.some
Expand Down

0 comments on commit 6775acf

Please sign in to comment.