nitin42 / terminal-in-react

👨‍💻 A component that renders a terminal
http://terminal-in-react.surge.sh/
MIT License
2.12k stars 151 forks source link

edit-line command return multiple lines instead of one #66

Open Alex100dre opened 5 years ago

Alex100dre commented 5 years ago

Hello, thanks for this awesome component 🙂

I tried to implement the type-text from advanced commands examples which use the edit-line built in command that is supposed to edit the last line.

commands={{
  'type-text': (args, print, runCommand) => {
    const text = args.slice(1).join(' ')
    print('')
    for (let i = 0; i < text.length; i += 1) {
      setTimeout(() => {
        runCommand(`edit-line ${text.slice(0, i + 1)}`)
      }, 100 * i)
    }
  },
}}

But instead of getting the last line updating, it return a new line at each iteration.

> type-text hello

h
he
hel
hell
hello

Any idea of what could cause this? 🤔

JustinMartinDev commented 5 years ago

@Alex100dre i got the same issue did you fix it ?

Alex100dre commented 5 years ago

Sadly not. I didn't spent time on it for the moment.

Let me know if you find something.

I'll do the same on my side.

HugoLiconV commented 4 years ago

any solution?