From 2e333b3571c08e80fe26c309bea60a2b28592633 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Fri, 21 Jan 2022 17:06:56 +0330 Subject: [PATCH] Shell: Make SimpleVariable::hit_test_position not hit irrelevant offsets Without this, any offset would be accepted as being part of the SimpleVariable. Fixes #11976 (by making it no longer crash). --- Userland/Shell/AST.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Shell/AST.cpp b/Userland/Shell/AST.cpp index 46d3db24ec..a59c6b328e 100644 --- a/Userland/Shell/AST.cpp +++ b/Userland/Shell/AST.cpp @@ -2843,6 +2843,9 @@ void SimpleVariable::highlight_in_editor(Line::Editor& editor, Shell& shell, Hig HitTestResult SimpleVariable::hit_test_position(size_t offset) const { + if (!position().contains(offset)) + return {}; + if (m_slice && m_slice->position().contains(offset)) return m_slice->hit_test_position(offset);