fix: mode doesn't work correctly (#128)
closes #122 please read the conversation to understand this change The bug was that the reset-mode-to-config-default logic already existed in the code (activeMode = loadMode()) but sat in a switch case that could never execute, the bytes it matched (\r, \n, Ctrl+C, Ctrl+U) were already intercepted and handled earlier in the same loop iteration with an unconditional continue, so control never reached that switch
This commit is contained in:
+9
-13
@@ -899,6 +899,9 @@ func runWrapper() {
|
|||||||
naiveBuffer = ""
|
naiveBuffer = ""
|
||||||
cursorOffset = 0
|
cursorOffset = 0
|
||||||
bufferMu.Unlock()
|
bufferMu.Unlock()
|
||||||
|
activeModeMu.Lock()
|
||||||
|
activeMode = loadMode()
|
||||||
|
activeModeMu.Unlock()
|
||||||
disableGhostText.Store(false)
|
disableGhostText.Store(false)
|
||||||
shouldOverlayDraw = false
|
shouldOverlayDraw = false
|
||||||
userNavigated.Store(false)
|
userNavigated.Store(false)
|
||||||
@@ -911,6 +914,9 @@ func runWrapper() {
|
|||||||
naiveBuffer = ""
|
naiveBuffer = ""
|
||||||
cursorOffset = 0
|
cursorOffset = 0
|
||||||
bufferMu.Unlock()
|
bufferMu.Unlock()
|
||||||
|
activeModeMu.Lock()
|
||||||
|
activeMode = loadMode()
|
||||||
|
activeModeMu.Unlock()
|
||||||
isCommandActive.Store(true)
|
isCommandActive.Store(true)
|
||||||
_, _ = ptmx.Write([]byte{b}) // forward enter to terminal
|
_, _ = ptmx.Write([]byte{b}) // forward enter to terminal
|
||||||
disableGhostText.Store(false)
|
disableGhostText.Store(false)
|
||||||
@@ -1078,6 +1084,9 @@ func runWrapper() {
|
|||||||
naiveBuffer = ""
|
naiveBuffer = ""
|
||||||
cursorOffset = 0
|
cursorOffset = 0
|
||||||
bufferMu.Unlock()
|
bufferMu.Unlock()
|
||||||
|
activeModeMu.Lock()
|
||||||
|
activeMode = loadMode()
|
||||||
|
activeModeMu.Unlock()
|
||||||
disableGhostText.Store(false)
|
disableGhostText.Store(false)
|
||||||
shouldOverlayDraw = false
|
shouldOverlayDraw = false
|
||||||
userNavigated.Store(false)
|
userNavigated.Store(false)
|
||||||
@@ -1160,19 +1169,6 @@ func runWrapper() {
|
|||||||
case 0x0c: // ctrl+l: clear screen but keep buffer and redraw menu
|
case 0x0c: // ctrl+l: clear screen but keep buffer and redraw menu
|
||||||
shouldOverlayDraw = true
|
shouldOverlayDraw = true
|
||||||
userNavigated.Store(false)
|
userNavigated.Store(false)
|
||||||
case '\r', '\n', 0x03, 0x15: // enter, ctrl+c, ctrl+u: clear buffer on line reset
|
|
||||||
inBracketedPaste = false
|
|
||||||
bufferMu.Lock()
|
|
||||||
naiveBuffer = ""
|
|
||||||
cursorOffset = 0
|
|
||||||
bufferMu.Unlock()
|
|
||||||
activeModeMu.Lock()
|
|
||||||
activeMode = loadMode()
|
|
||||||
activeModeMu.Unlock()
|
|
||||||
disableGhostText.Store(false)
|
|
||||||
writeStdout([]byte(overlay.ClearAndDisable()))
|
|
||||||
SetCurrentAISuggestion(nil)
|
|
||||||
userNavigated.Store(false)
|
|
||||||
default:
|
default:
|
||||||
// track normal printable characters in the buffer for matching
|
// track normal printable characters in the buffer for matching
|
||||||
if b >= 32 && b <= 126 {
|
if b >= 32 && b <= 126 {
|
||||||
|
|||||||
Reference in New Issue
Block a user