fix(config): resolve enter key submission and keybinding issues (#89)

closes #88
closes #85
This commit is contained in:
VERSE
2026-07-31 18:38:31 +07:00
committed by GitHub
parent 85a9a7d55d
commit 235a7f98ea
3 changed files with 54 additions and 9 deletions
+19 -9
View File
@@ -747,18 +747,24 @@ func runWrapper() {
i += navConsumed - 1
continue
} else if naiveBuffer == "" {
// up/down arrow on empty prompt
} else {
// up/down arrow or navigation key when overlay is closed
intercepted = true
activeModeMu.Lock()
activeMode = "history"
saveMode(activeMode)
if activeMode == "" {
activeMode = loadMode()
}
activeModeMu.Unlock()
activeModeMu.RLock()
currentMode := activeMode
activeModeMu.RUnlock()
results := MergeResults("", currentMode)
bufferMu.Lock()
bufQuery := naiveBuffer
bufferMu.Unlock()
results := MergeResults(bufQuery, currentMode)
if len(results) > 0 {
limit := min(len(results), 100)
var historyList []spec.Suggestion
@@ -791,8 +797,8 @@ func runWrapper() {
}
if matched, consumed := config.MatchKey(inputSlice[i:], config.Get().Keybindings.SelectSuggestion); matched && config.Get().Keybindings.SelectSuggestion != "" {
intercepted = true
if overlay.IsVisible() {
intercepted = true
selected := overlay.GetCurrentCmd()
if selected != "" {
activeModeMu.RLock()
@@ -816,18 +822,22 @@ func runWrapper() {
userNavigated.Store(false)
writeStdout([]byte(overlay.Render()))
}
i += consumed - 1
continue
}
i += consumed - 1
continue
}
if b == 0x0d || b == 0x0a { // enter
intercepted = true
logger.Debugf("Intercepted Enter key")
if b == 0x0d && i+1 < n && inputSlice[i+1] == 0x0a {
i++ // consume trailing \n in \r\n to prevent matching ctrl+j
}
var selectedCmd string
var shouldAutoExecute bool
if config.Get().Core.AutoExecute && overlay.IsVisible() {
if overlay.IsVisible() && (config.Get().Core.AutoExecute || userNavigated.Load()) {
selectedCmd = overlay.GetCurrentCmd()
if selectedCmd != "" {
shouldAutoExecute = true