go-prompt
go-prompt copied to clipboard
[Bug] Multi-line Ctrl-V support
Bug reports
I'm trying to insert multi-line code snippet, e.g:
res = {}
for i=1,5 do
table.insert(res, 1)
end
and i get this:
end
but buffer is valid — if i press enter key, code execute normally.
Expected Behavior
Correct display of the code snippet.
Details
I looked at the source code, and it said that \n
translates to \r
.
After that, I tried to make my Ctrl-V handler like this:
Key: prompt.ControlV,
Fn: func(buf *prompt.Buffer) {
text := buf.Text()
buf.DeleteBeforeCursor(len(text))
buf.InsertText(strings.Replace(text, "\r", "\n", -1), false, true)
}
but in this case, Render update screen invalid and i get (for every keystroke, e.g changing the cursor keys: left, right) something like this:
myapp.s1-master> res = {}
for i=1,5 do
table.insert(res, 1)
myapp.s1-master> res = {}
for i=1,5 do
table.insert(res, 1)
myapp.s1-master> res = {}
for i=1,5 do
table.insert(res, 1)
myapp.s1-master> res = {}
for i=1,5 do
table.insert(res, 1)
myapp.s1-master> res = {}
for i=1,5 do
table.insert(res, 1)
myapp.s1-master> res = {}
for i=1,5 do
table.insert(res, 1)
end
looking at the source code (render.go), I realized that at the moment only single lines are supported :(
I found a fork that solves this issue: https://github.com/binaek89/go-prompt