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

Can not navigator with arrow keys #8

Closed
aztack opened this issue May 18, 2022 · 15 comments · Fixed by #10
Closed

Can not navigator with arrow keys #8

aztack opened this issue May 18, 2022 · 15 comments · Fixed by #10

Comments

@aztack
Copy link

aztack commented May 18, 2022

image

I tried zsh/bash/fish with iTerm2.app and Terminal.app. None of them works.

@Araxeus
Copy link
Owner

Araxeus commented May 18, 2022

That's weird, this app uses https://github.com/mitsuhiko/dialoguer for the select prompt

Could you try a few things to help me pinpoint the origin of this?

It looks like it's maybe not waiting for input, just printing the prompt and exiting which shouldn't happen...

@marcoil
Copy link

marcoil commented May 18, 2022

Same problem here on Ubuntu 20.04, both with gnome-terminal and Tilix. Arrow keys do work on the 1.2.0 release, but not Shift+Enter or Ctrl+Enter. Pressing those just goes into the directory just like pressing Enter without modifiers.

@Araxeus
Copy link
Owner

Araxeus commented May 18, 2022

Same problem here on Ubuntu 20.04, both with gnome-terminal and Tilix. Arrow keys do work on the 1.2.0 release, but not Shift+Enter or Ctrl+Enter. Pressing those just goes into the directory just like pressing Enter without modifiers.

This sounds like a problem with lsi.sh

Maybe it doesn't wait for the program to complete executing

Can you try running ls-interactive (v1.3.0) instead of lsi and see if it works?

@marcoil
Copy link

marcoil commented May 18, 2022

Can you try running ls-interactive (v1.3.0) instead of lsi and see if it works?

Exactly the same bug, it's not even possible to exit with Esc, I have to ^C kill it.

@Araxeus
Copy link
Owner

Araxeus commented May 18, 2022

Can you try running ls-interactive (v1.3.0) instead of lsi and see if it works?

Exactly the same bug, it's not even possible to exit with Esc, I have to ^C kill it.

Thank you, that helps understanding where it might be coming from

Since v1.2 works but v1.3 doesn't, It's probably about the new "Fuzzy select" feature

I will look into it.

If you have rust installed you could try forking the repo and in utils.rs change both instances of FuzzySelect to just Select and try running cargo run

It's hard for me to debug this, since I'm personally using windows and it works perfectly there :/

@marcoil
Copy link

marcoil commented May 18, 2022

change both instances of FuzzySelect to just Select and try running cargo run

I just tried this but I got the same bug :( It looks like a terminal problem, as the codes I get on stdout (^[[B, ^[[A…) are uninterpreted terminal escape codes. Let me know if you need to test something else, although I'm not familiar with either Rust or terminal programming so I won't be of much help.

@Araxeus
Copy link
Owner

Araxeus commented May 18, 2022

can you try changing the following in Cargo.toml (add branch)

[patch.crates-io]
dialoguer = { git = 'https://github.com/araxeus/dialoguer', branch = 'unix_fix' }

(Enabled 'raw mode' before capturing key, might help)

(also beware because this will disable ^C for now)


if this still doesn't work, I'll try to get a Linux laptop from a friend this weekend and see if I can fix this

@marcoil
Copy link

marcoil commented May 19, 2022

With the unix_fix branch the input issue is solved, at least for arrow keys and using Esc to exit \o/

There are still some issues, I can open new tickets or help you debug in this one:

  • Shift+Enter and Ctrl+Enter are still just Enter.
  • When entering a directory, the listing is shown indented (as in the attached shot) until you move the cursor, then it's shown correctly. This doesn't happen with the first directory, only when entering a new one.

ls-interactive entering dir

@Araxeus
Copy link
Owner

Araxeus commented May 19, 2022

With the unix_fix branch the input issue is solved, at least for arrow keys and using Esc to exit \o/

Well I'm glad the original issue is fixed at least 😁

  • Shift+Enter and Ctrl+Enter are still just Enter

Did you try v1.3.0 and reverted to FuzzySelect?

  • When entering a directory, the listing is shown indented (as in the attached shot) until you move the cursor, then it's shown correctly. This doesn't happen with the first directory, only when entering a new one.

ls-interactive entering dir

I suspect this might be because raw mode is enabled, might have to disable it before # re-rendering the list


Also could you confirm that fuzzy select works? (If you type letters - it filters the current list)

Thanks a lot for your help !

@marcoil
Copy link

marcoil commented May 20, 2022

Did you try v1.3.0 and reverted to FuzzySelect?

Right, sorry. I re-enabled FuzzySelect and it does work, although with the same indentation problem:
ls-interactive fuzzy select

Thank you for the project, I really like the idea!

@Araxeus Araxeus mentioned this issue May 20, 2022
@Araxeus
Copy link
Owner

Araxeus commented May 20, 2022

Got my hands on a Linux laptop and fixed most problems in #10

(the installation setup on Linux/Mac changed too)


Sadly Ctrl+Enter still doesn't work
but you can use Alt+Enterinstead of Shift+Enter

this is a bug in crossterm, see crossterm-rs/crossterm#669

@Araxeus
Copy link
Owner

Araxeus commented May 21, 2022

@marcoil
Copy link

marcoil commented May 23, 2022

This is great, everything works on my end!

Well, except for actually changing into the directory at exit, as I'm using fish and not bash :P Supporting all the Linux variants can be somewhat difficult, so thanks for your efforts.

When I get a little time I'll try to provide zsh and fish alternatives.

@Araxeus
Copy link
Owner

Araxeus commented May 23, 2022

I don't actually know how fish behaves, but I think with some slight syntax change it might work:

function lsi
    set -l output (ls-interactive "$argv")
    if [ -n "$output" ]
        cd "$output"
    end
end

if you put this lsi function inside ~/.config/fish/config.fish does it work?
(you could instead add it as an autoloading function which seems to be the preferred way)

the function just needs to call ls-interactive, capture its output, and CD to the output if its not empty

and for Zsh you should be able to put the original function in zshrc or zshenv
(from what I know bash syntax should work in zsh?)

@marcoil
Copy link

marcoil commented May 26, 2022

I hadn't seen your last response, sorry. But I did make an equivalent fish function and put it in pull request #13, in case you want to merge it. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants