Fix bisect script run and level validators

This commit is contained in:
Joe Tretter
2026-06-26 19:00:51 -05:00
parent caaf26a541
commit d703f539d3
5 changed files with 79 additions and 4 deletions

View File

@@ -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('/') + "/"
}