Fix bisect script run and level validators
This commit is contained in:
@@ -24,6 +24,27 @@ internal fun directoryCompletionCandidates(repo: RepoState): List<String> {
|
||||
.distinct()
|
||||
}
|
||||
|
||||
internal fun contextualCompletionCandidates(
|
||||
candidates: List<String>,
|
||||
commandBeforeToken: String,
|
||||
token: String,
|
||||
directoriesOnly: Boolean,
|
||||
): List<String> {
|
||||
val matches = candidates.sorted().filter { it.startsWith(token) }
|
||||
if (directoriesOnly) return matches
|
||||
|
||||
val commandTokens = GitSandboxEngine.tokenizeCommand(commandBeforeToken.trim())
|
||||
if (commandTokens == listOf("git", "bisect", "run")) {
|
||||
val scriptMatches = matches.filter { candidate ->
|
||||
val normalized = candidate.removePrefix("./")
|
||||
normalized.endsWith(".sh") && '/' !in normalized && !normalized.startsWith(".")
|
||||
}
|
||||
if (scriptMatches.isNotEmpty()) return scriptMatches
|
||||
}
|
||||
|
||||
return matches
|
||||
}
|
||||
|
||||
private fun RepoState.currentDirPrefix(): String {
|
||||
return if (currentDir == ".") "" else currentDir.trimEnd('/') + "/"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user