Merge pull request #1658 from bas-vk/liner-ctrl-c
Clear current line on ctrl-C
This commit is contained in:
commit
cd81356ace
@ -383,6 +383,11 @@ func (self *jsre) interactive() {
|
|||||||
for {
|
for {
|
||||||
line, err := self.Prompt(<-prompt)
|
line, err := self.Prompt(<-prompt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == liner.ErrPromptAborted { // ctrl-C
|
||||||
|
self.resetPrompt()
|
||||||
|
inputln <- ""
|
||||||
|
continue
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
inputln <- line
|
inputln <- line
|
||||||
@ -467,6 +472,12 @@ func (self *jsre) parseInput(code string) {
|
|||||||
var indentCount = 0
|
var indentCount = 0
|
||||||
var str = ""
|
var str = ""
|
||||||
|
|
||||||
|
func (self *jsre) resetPrompt() {
|
||||||
|
indentCount = 0
|
||||||
|
str = ""
|
||||||
|
self.ps1 = "> "
|
||||||
|
}
|
||||||
|
|
||||||
func (self *jsre) setIndent() {
|
func (self *jsre) setIndent() {
|
||||||
open := strings.Count(str, "{")
|
open := strings.Count(str, "{")
|
||||||
open += strings.Count(str, "(")
|
open += strings.Count(str, "(")
|
||||||
|
Loading…
Reference in New Issue
Block a user