diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-18 20:43:57 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-18 20:44:31 +0200 |
commit | a1e7aa330cf50326b99a398293e582a551cbd8fb (patch) | |
tree | 6dc96a2a6f8680880fa8665339284828cf8bf7eb | |
parent | 4b202a3c79a1fa25c5dfe5e65fa98f897ffd223c (diff) | |
download | serenity-a1e7aa330cf50326b99a398293e582a551cbd8fb.zip |
HackStudio: Don't use an OOB TextRange when looking for hovered text
We could going +1 past the end of a TextDocumentLine here. This caused
us to crash in the brave new world, so we could find it. :^)
-rw-r--r-- | DevTools/HackStudio/Editor.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp index d813c40544..3e492caa74 100644 --- a/DevTools/HackStudio/Editor.cpp +++ b/DevTools/HackStudio/Editor.cpp @@ -234,7 +234,8 @@ void Editor::mousemove_event(GUI::MouseEvent& event) if (span.range.contains(text_position)) { auto adjusted_range = span.range; - adjusted_range.end().set_column(adjusted_range.end().column() + 1); + auto end_line_length = document().line(span.range.end().line()).length(); + adjusted_range.end().set_column(min(end_line_length, adjusted_range.end().column() + 1)); auto hovered_span_text = document().text_in_range(adjusted_range); #ifdef EDITOR_DEBUG dbg() << "Hovering: " << adjusted_range << " \"" << hovered_span_text << "\""; |