Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Multi-line Ctrl-V support #227

Open
mRrvz opened this issue Mar 28, 2021 · 1 comment
Open

[Bug] Multi-line Ctrl-V support #227

mRrvz opened this issue Mar 28, 2021 · 1 comment
Labels

Comments

@mRrvz
Copy link

mRrvz commented Mar 28, 2021

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 :(

@mRrvz mRrvz added the bug label Mar 28, 2021
@mRrvz
Copy link
Author

mRrvz commented Mar 30, 2021

I found a fork that solves this issue: https://github.com/binaek89/go-prompt

aranjan7 added a commit to maira-io/go-prompt that referenced this issue May 28, 2022
this is ported from here.
binaek@7e13943

bug detail:
c-bata#227
vkrizan pushed a commit to vkrizan/go-prompt that referenced this issue Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant