mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-23 04:28:55 -04:00
fix dead end error with executable literal nodes
This commit is contained in:
parent
7191fdcb76
commit
d1451bd863
@ -48,6 +48,18 @@ abstract class ExecutableNode(
|
||||
super.execute(reader, stack)
|
||||
}
|
||||
|
||||
override fun getSuggestions(reader: CommandReader, stack: CommandStack): List<Any?> {
|
||||
if (!reader.canPeek()) {
|
||||
// empty string
|
||||
if (executable) {
|
||||
return emptyList()
|
||||
} else {
|
||||
checkForDeadEnd(reader)
|
||||
}
|
||||
}
|
||||
return super.getSuggestions(reader, stack)
|
||||
}
|
||||
|
||||
override fun executeChild(child: CommandNode, reader: CommandReader, stack: CommandStack) {
|
||||
super.executeChild(child, reader, stack)
|
||||
if (!onlyDirectExecution) {
|
||||
|
@ -35,7 +35,7 @@ internal class SuggestionChildReadingTest {
|
||||
.addChild(
|
||||
LiteralNode("1_literal")
|
||||
.addChild(LiteralNode("1_literal_2"))
|
||||
.addChild(LiteralNode("2_literal_2"))
|
||||
.addChild(LiteralNode("2_literal_2", executable = true))
|
||||
)
|
||||
.addChild(LiteralNode("2_literal"))
|
||||
.addChild(
|
||||
@ -152,4 +152,9 @@ internal class SuggestionChildReadingTest {
|
||||
fun testStringOptionalArguments() {
|
||||
assertDoesNotThrow { createCommand().getSuggestions(CommandReader("3_literal string"), CommandStack()) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoSuggestionsErrors() {
|
||||
assertEquals(createCommand().getSuggestions(CommandReader("1_literal 2_literal_2"), CommandStack()), emptyList())
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user