You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running Debian (sid) with Alacritty as my terminal emulator. (I can also reproduce the issue below with Gnome Terminal.)
If I call the Prompt method with a long string and then send a SIGINT, the program will exit (with a status code of 1) instead of cancelling the prompt. This example reproduces it:
package main
import (
"fmt""reflect""strings""github.com/peterh/liner"
)
funcmain() {
l:=liner.NewLiner()
cols:=int(reflect.ValueOf(l).Elem().FieldByName("columns").Int())
varerrerror// Ctrl-C resets the prompt, as expected._, err=l.Prompt(genString(cols-10))
fmt.Printf("err: %v\n", err)
// This kills the program when hitting Ctrl-C, exiting with a status code of 1._, err=l.Prompt(genString(cols-9))
fmt.Printf("err: %v\n", err)
}
funcgenString(nint) string {
vars strings.Builderfori:=0; i<n; i++ {
s.WriteString("a")
}
returns.String()
}
The issue is the call here to the ReadLine method from bufio. (This is reached from this region.)
I'm not (immediately) sure what the right fix would be. You've no doubt thought a lot more about these kinds of questions than I have—what do you think?
The text was updated successfully, but these errors were encountered:
I'm not (immediately) sure what the right fix would be. You've no doubt thought a lot more about these kinds of questions than I have—what do you think?
I think that prompts should be short and to the point. > or similar, with maybe a single word to indicate mode or perhaps one number (eg. line number or sequence number) at most.
I think that the correct fix is to document that liner.Prompt will go into "unsupported mode" if you try to use a long prompt (which is what it does and why you see Ctrl-C breaking). I realize that this doesn't help when the user shrinks their terminal emulator to a tragically small width, but liner isn't really useful in that scenario anyway.
Thanks for getting back to me—I agree about the shape an appropriate prompt ought to have and that documentation is probably the best approach. I know that the above example of mine is... pathological...
I'm running Debian (sid) with Alacritty as my terminal emulator. (I can also reproduce the issue below with Gnome Terminal.)
If I call the
Prompt
method with a long string and then send a SIGINT, the program will exit (with a status code of 1) instead of cancelling the prompt. This example reproduces it:The issue is the call here to the
ReadLine
method from bufio. (This is reached from this region.)I'm not (immediately) sure what the right fix would be. You've no doubt thought a lot more about these kinds of questions than I have—what do you think?
The text was updated successfully, but these errors were encountered: