File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
src/endstone/core/command Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,14 @@ std::string_view parseNode(const CommandRegistry::ParseToken &root)
9494
9595 // Otherwise:
9696 const auto &child = *root.child ;
97- auto *begin = findFirstWithText (&child)->text ;
97+ const auto *begin = findFirstWithText (&child);
98+ if (!begin) {
99+ return " " ;
100+ }
98101
99102 // (1) If this node has no next sibling, it's the last argument: consume all remaining text until the end
100103 if (!root.next ) {
101- const auto view = rstrip (begin);
104+ const auto view = rstrip (begin-> text );
102105 if (child.type == CommandRegistry::HardNonTerminal::Id) {
103106 return removeQuotes (view);
104107 }
@@ -107,8 +110,16 @@ std::string_view parseNode(const CommandRegistry::ParseToken &root)
107110
108111 // (2) Otherwise, find the start of the next argument and extract the substring between begin and end, then trim
109112 // trailing whitespace.
110- auto *end = findFirstWithText (root.next .get ())->text ;
111- const auto view = rstrip ({begin, end});
113+ const auto *end = findFirstWithText (root.next .get ());
114+ if (!end) {
115+ const auto view = rstrip (begin->text );
116+ if (child.type == CommandRegistry::HardNonTerminal::Id) {
117+ return removeQuotes (view);
118+ }
119+ return view;
120+ }
121+
122+ const auto view = rstrip ({begin->text , end->text });
112123 if (child.type == CommandRegistry::HardNonTerminal::Id) {
113124 return removeQuotes (view);
114125 }
You can’t perform that action at this time.
0 commit comments