Comments (19)
I did a workaround for this issue by disabling line wrap before calling into the package to ask the questions.
// make terminal not line wrap
fmt.Printf("\x1b[?7l")
// defer restoring line wrap
defer fmt.Printf("\x1b[?7h")
from survey.
We can finally close this!! 🎉🎉🎉
Thank you so much @coryb and @Zalgo2462! Like i said, this has been a problem for a very very long time. Thank you for seeing this through
from survey.
Just verified that this also affects OSX terminals. Thanks for bringing this to my attention @geocine!
from survey.
The issue happens because https://github.com/AlecAivazis/survey/blob/master/core/renderer.go#L77 doesn't take wrapping into account (i.e. when the terminal wraps, it adds extra \n
that were not present in the initial rendered template) resulting in resetPrompt
erasing only (original number of lines - number of wrapped lines) lines.
from survey.
@AlecAivazis any idea on when this issue could be fixed?
from survey.
Gah! Sorry to hear this, i'll try to fix it ASAP - do you by chance have access to a linux machine and could see if it's affecting you there too? I'm pretty sure I verified overflow behavior on a posix terminal but there might be something special with your question or prompt.
from survey.
@AlecAivazis, I don't have an access even to Linux VM, but I assume, this bug doesn't affect only password asking. Same "overflowing" behaviour with select option.
from survey.
Okay no worries @frodgesh . Since I'm currently on a windows machine I figured I leave a note to my future self that I was able to reproduce this with the ask
test and a very thin cmd.exe
terminal. It only duplicated on clean-up.
from survey.
Running into this problem now on macOS! I had a look through the source code but can't find anything obvious that could be causing this.
The funny thing is that the same thing also happens with another popular CLI prompt (promptui). At first I thought it might be related to promptui's dependency on readline but apparently that's not it.
Any hunches as to what could be causing this?
from survey.
do you by chance have access to a linux machine and could see if it's affecting you there too?
Hi @AlecAivazis we are currently using this package for implementing a command in our project and I experienced the same issue on my machine (OS: Ubuntu 16.04, shell: zsh).
Please let me know when its fixed 😄
from survey.
issue confirmed (OS: Ubuntu 18.04.1, shell: zsh). Another workaround may be get terminal column size then insert new lines at that index before rendering text.
from survey.
Perhaps it would be worth using a terminal emulation library to deal with this issue, though of course that would mean adding another dependency…
from survey.
This is biting me too. Any ideas on how to fix?
from survey.
I had taken a quick look but there was no obvious solution with the current implementation as it doesn't have access to the text being currently displayed (iirc). As a workaround, I wrap lines "manually" before handing text that I know might wrap to survey… Not ideal.
from survey.
I think the most suitable solution would be:
- Implementing a watchdog for terminal size, as this issue also happens when terminal resize.
- Send an event to renderer/writer to re-draw the prompt if line lengths exceed terminal width.
- Re-draw and add "\n" to avoid unwanted glitches.
I use a similar mechanism on a project but it's not public at the moment. So, I can't link the code here. Although I don't use survey, things work similar.
from survey.
Seeing this in Linux terminals as well, not just OSX.
from survey.
I managed to "fix" this by disabling the "Message" part of the prompt.
from survey.
I also noticed that if you press "?" for a help message (when that feature is being used) and then press a different key the help message will be re-printed instead of the original message (presumably since it's the last thing that was displayed?). Not sure if that helps with debugging.
from survey.
seeing this in Konsole as well. Prompt reprints instead of refreshing terminal.
Behavior is not present in Gnome Terminal or Xterm.
- Konsole 19.12.3
- KDE 5.18.14
- Linux apple-2 5.4.31-1-MANJARO #1 SMP PREEMPT Wed Apr 8 10:25:32 UTC 2020 x86_64 GNU/Linux
from survey.
Related Issues (20)
- jungaretti:jungaretti/add-proto-guide HOT 1
- Please update golang.org/x/text v0.3.3 to latest version due to security issues
- Support for `fmt.Stringer` interface to display structs in `Select`/`MultiSelect`
- how can I disable text color on Select description text? HOT 1
- multiple selection,get the key from the console by default
- Question duplicates on windows cmd HOT 7
- Arrow keys providing garbage input under Windows HOT 1
- Raid1
- template: prompt:4:19: executing "option" at <.CurrentOpt.Value>: can't evaluate field Value in type bgUEpkv_iHV.IA6nAoo
- Ability to 'clear' terminal
- survey.Multiline The display of the input at the bottom of the terminal is covered
- Why survery.v1 go.mod need import survery v2
- How to disable Logic of Cleanup in Prompt HOT 1
- Prompt like "form prompt" from Enquirer
- Support configurable template data
- MultiSelect options spanning multiple columns HOT 1
- Pagination - shortcut key to paginate (page up or page down)
- Excuse me, how to remove the question mark at the beginning of the question? HOT 1
- mips64le not supported
- add a a whiptail/dialog replacement as an example script
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from survey.