Giter VIP home page Giter VIP logo

Comments (19)

AnthonyPoschen avatar AnthonyPoschen commented on May 30, 2024 4

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.

AlecAivazis avatar AlecAivazis commented on May 30, 2024 4

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.

AlecAivazis avatar AlecAivazis commented on May 30, 2024 2

Just verified that this also affects OSX terminals. Thanks for bringing this to my attention @geocine!

from survey.

metacosm avatar metacosm commented on May 30, 2024 1

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.

metacosm avatar metacosm commented on May 30, 2024 1

@AlecAivazis any idea on when this issue could be fixed?

from survey.

AlecAivazis avatar AlecAivazis commented on May 30, 2024

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.

 avatar commented on May 30, 2024

@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.

AlecAivazis avatar AlecAivazis commented on May 30, 2024

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.

capture

from survey.

DeepAnchor avatar DeepAnchor commented on May 30, 2024

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.

palash25 avatar palash25 commented on May 30, 2024

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.

isacikgoz avatar isacikgoz commented on May 30, 2024

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.

metacosm avatar metacosm commented on May 30, 2024

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.

jorng avatar jorng commented on May 30, 2024

This is biting me too. Any ideas on how to fix?

from survey.

metacosm avatar metacosm commented on May 30, 2024

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.

isacikgoz avatar isacikgoz commented on May 30, 2024

I think the most suitable solution would be:

  1. Implementing a watchdog for terminal size, as this issue also happens when terminal resize.
  2. Send an event to renderer/writer to re-draw the prompt if line lengths exceed terminal width.
  3. 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.

th3coop avatar th3coop commented on May 30, 2024

Seeing this in Linux terminals as well, not just OSX.

from survey.

PrMinisterGR avatar PrMinisterGR commented on May 30, 2024

I managed to "fix" this by disabling the "Message" part of the prompt.

from survey.

sgreene570 avatar sgreene570 commented on May 30, 2024

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.

bcatubig avatar bcatubig commented on May 30, 2024

image

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.