mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-02 04:20:28 +00:00
Shell: Don't crash when autocompleting a non-bare word
For example, type 'Hello?' without the quotation marks but with the question mark, and press TAB. Previously, this would crash the Shell. Now, it merely refuses to make any suggestions. We could do better, but that is too hard for now.
This commit is contained in:
parent
4ad6315fda
commit
782db88e82
Notes:
sideshowbarker
2024-07-19 04:37:48 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/782db88e826 Pull-request: https://github.com/SerenityOS/serenity/pull/2874 Reviewed-by: https://github.com/alimpfard ✅
1 changed files with 3 additions and 6 deletions
|
@ -441,10 +441,9 @@ HitTestResult CastToCommand::hit_test_position(size_t offset)
|
|||
Vector<Line::CompletionSuggestion> CastToCommand::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result)
|
||||
{
|
||||
auto matching_node = hit_test_result.matching_node;
|
||||
if (!matching_node)
|
||||
if (!matching_node || !matching_node->is_bareword())
|
||||
return {};
|
||||
|
||||
ASSERT(matching_node->is_bareword());
|
||||
auto corrected_offset = offset - matching_node->position().start_offset;
|
||||
auto* node = static_cast<BarewordLiteral*>(matching_node.ptr());
|
||||
|
||||
|
@ -953,10 +952,9 @@ HitTestResult Execute::hit_test_position(size_t offset)
|
|||
Vector<Line::CompletionSuggestion> Execute::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result)
|
||||
{
|
||||
auto matching_node = hit_test_result.matching_node;
|
||||
if (!matching_node)
|
||||
if (!matching_node || !matching_node->is_bareword())
|
||||
return {};
|
||||
|
||||
ASSERT(matching_node->is_bareword());
|
||||
auto corrected_offset = offset - matching_node->position().start_offset;
|
||||
auto* node = static_cast<BarewordLiteral*>(matching_node.ptr());
|
||||
|
||||
|
@ -1204,10 +1202,9 @@ HitTestResult PathRedirectionNode::hit_test_position(size_t offset)
|
|||
Vector<Line::CompletionSuggestion> PathRedirectionNode::complete_for_editor(Shell& shell, size_t offset, const HitTestResult& hit_test_result)
|
||||
{
|
||||
auto matching_node = hit_test_result.matching_node;
|
||||
if (!matching_node)
|
||||
if (!matching_node || !matching_node->is_bareword())
|
||||
return {};
|
||||
|
||||
ASSERT(matching_node->is_bareword());
|
||||
auto corrected_offset = offset - matching_node->position().start_offset;
|
||||
auto* node = static_cast<BarewordLiteral*>(matching_node.ptr());
|
||||
|
||||
|
|
Loading…
Reference in a new issue