mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 11:34:54 -04:00
Fix potential crash in console autocomplete (#11568)
This commit is contained in:
parent
0f4b52aaea
commit
7bbe218bf0
@ -73,9 +73,11 @@ open class ConsoleAction(val format: String, val action: (console: DevConsolePop
|
|||||||
it.removeSurrounding("<",">").removeSurrounding("[","]").removeSurrounding("\"")
|
it.removeSurrounding("<",">").removeSurrounding("[","]").removeSurrounding("\"")
|
||||||
}
|
}
|
||||||
if (formatParams.size < params.size) return ""
|
if (formatParams.size < params.size) return ""
|
||||||
val formatParam = formatParams[params.lastIndex]
|
// It is possible we're here *with* another format parameter but an *empty* params (e.g. `tile addriver ` and hit tab) -> see else branch
|
||||||
|
val (formatParam, lastParam) = if (params.lastIndex in formatParams.indices)
|
||||||
|
formatParams[params.lastIndex] to params.last()
|
||||||
|
else formatParams.first() to ""
|
||||||
|
|
||||||
val lastParam = params.last()
|
|
||||||
val options = when (formatParam) {
|
val options = when (formatParam) {
|
||||||
"civName" -> console.gameInfo.civilizations.map { it.civName }
|
"civName" -> console.gameInfo.civilizations.map { it.civName }
|
||||||
"unitName" -> console.gameInfo.ruleset.units.keys
|
"unitName" -> console.gameInfo.ruleset.units.keys
|
||||||
|
Loading…
x
Reference in New Issue
Block a user