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

Insert keymap doesnt work #1485

Closed
og900aero opened this issue Aug 14, 2024 · 11 comments
Closed

Insert keymap doesnt work #1485

og900aero opened this issue Aug 14, 2024 · 11 comments
Labels
bug Something isn't working upstream

Comments

@og900aero
Copy link

What system are you running Yazi on?

Linux X11

What terminal are you running Yazi in?

st 0.9.1

yazi --debug output

╰─$ yazi --debug

Yazi
    Version: 0.3.0 (c75960e 2024-08-14)
    Debug  : false
    OS     : linux-x86_64 (unix)

Ya
    Version: 0.3.0

Emulator
    Emulator.via_env: ("st-256color", "")
    Emulator.via_csi: Ok(Unknown([]))
    Emulator.detect : Unknown([])

Adapter
    Adapter.matches: X11

Desktop
    XDG_SESSION_TYPE: Some("tty")
    WAYLAND_DISPLAY : None
    DISPLAY         : Some(":0")

SSH
    shared.in_ssh_connection: false

WSL
    /proc/sys/fs/binfmt_misc/WSLInterop: false

Variables
    SHELL              : Some("/bin/bash")
    EDITOR             : Some("micro")
    YAZI_FILE_ONE      : None
    YAZI_CONFIG_HOME   : None
    ZELLIJ_SESSION_NAME: None

Text Opener
    default: Some(Opener { run: "$EDITOR \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })
    block  : Some(Opener { run: "$EDITOR \"$@\"", block: true, orphan: false, desc: "$EDITOR", for_: None, spread: true })

tmux
    TMUX   : false
    Version: tmux 3.3a

Dependencies
    file             : 5.44
    ueberzugpp       : 2.9.6
    ffmpegthumbnailer: 2.2.2
    magick           : No such file or directory (os error 2)
    fzf              : 0.50.0
    fd               : No such file or directory (os error 2)
    rg               : 13.0.0
    chafa            : 1.12.4
    zoxide           : 0.4.3
    7z               : No such file or directory (os error 2)
    7zz              : 22.01
    jq               : 1.6

Did you try the latest nightly build to see if the problem got fixed?

Yes, and I updated the debug information above (yazi --debug) to the nightly that I tried

Describe the bug

When I mount Insert keyboard to the create function, it doesnt work/nothing happaned.

{ on = [ "<Insert>" ], run = "create", desc = "Create a file or directory (ends with / for directories)" },

Minimal reproducer

I use this code:

{ on = [ "<Insert>" ], run = "create", desc = "Create a file or directory (ends with / for directories)" },

Anything else?

No response

@og900aero og900aero added the bug Something isn't working label Aug 14, 2024
@sxyazi
Copy link
Owner

sxyazi commented Aug 14, 2024

Please apply this patch and build Yazi in debug mode, then check the log file to see what key was reported

--- yazi/yazi-fm/src/app/app.rs
+++ yazi/yazi-fm/src/app/app_new.rs
@@ -81,7 +81,10 @@
 	fn dispatch_render(&mut self) { NEED_RENDER.store(true, Ordering::Relaxed); }
 
 	#[inline]
-	fn dispatch_key(&mut self, key: KeyEvent) { Router::new(self).route(Key::from(key)); }
+	fn dispatch_key(&mut self, key: KeyEvent) {
+		tracing::error!(?key);
+		Router::new(self).route(Key::from(key));
+	}
 
 	#[inline]
 	fn dispatch_paste(&mut self, str: String) {

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Aug 14, 2024
@og900aero
Copy link
Author

I did it, but I nothing special, when I press Insert:

  2024-08-14T11:16:01.351090Z  WARN yazi_adapter::emulator: [Adapter] No special environment variables detected
    at yazi-adapter/src/emulator.rs:70

  2024-08-14T11:16:01.351105Z  WARN yazi_adapter::emulator: [Adapter] Unknown TERM_PROGRAM: 
    at yazi-adapter/src/emulator.rs:84

  2024-08-14T11:16:01.351107Z  WARN yazi_adapter::emulator: [Adapter] Unknown TERM: st-256color
    at yazi-adapter/src/emulator.rs:92

  2024-08-14T11:16:01.351588Z  WARN yazi_adapter::adapter: [Adapter] Could not identify XDG_SESSION_TYPE
    at yazi-adapter/src/adapter.rs:101

  2024-08-14T11:16:01.364133Z ERROR yazi_plugin::utils::call: Failed to `render()` the `status` component:
runtime error: [string "init.lua"]:37: attempt to index a nil value (field 'hovered')
stack traceback:
	[C]: in metamethod 'index'
	[string "init.lua"]:37: in method 'modified'
	[string "init.lua"]:57: in function <[string "init.lua"]:56>
	[C]: in field 'render_with'
	[string "root.lua"]:35: in function <[string "root.lua"]:32>
    at yazi-plugin/src/utils/call.rs:63

  2024-08-14T11:16:01.366056Z ERROR yazi_plugin::utils::call: Failed to `render()` the `status` component:
runtime error: [string "init.lua"]:37: attempt to index a nil value (field 'hovered')
stack traceback:
	[C]: in metamethod 'index'
	[string "init.lua"]:37: in method 'modified'
	[string "init.lua"]:57: in function <[string "init.lua"]:56>
	[C]: in field 'render_with'
	[string "root.lua"]:35: in function <[string "root.lua"]:32>
    at yazi-plugin/src/utils/call.rs:63

  2024-08-14T11:16:01.374990Z ERROR yazi_plugin::utils::call: Failed to `render()` the `status` component:
runtime error: [string "init.lua"]:37: attempt to index a nil value (field 'hovered')
stack traceback:
	[C]: in metamethod 'index'
	[string "init.lua"]:37: in method 'modified'
	[string "init.lua"]:57: in function <[string "init.lua"]:56>
	[C]: in field 'render_with'
	[string "root.lua"]:35: in function <[string "root.lua"]:32>
    at yazi-plugin/src/utils/call.rs:63


@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Aug 14, 2024
@sxyazi
Copy link
Owner

sxyazi commented Aug 14, 2024

When you press other keys, do they also not appear in the log? If so, it's likely that you didn't apply the patch correctly

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Aug 14, 2024
@og900aero
Copy link
Author

og900aero commented Aug 14, 2024

Other keys also not appear. Hmm...I do the following commands:

  1. micro patch.new
  2. then insert yout code
  3. patch yazi-fm/src/app/app.rs patch.new
  4. cargo build --release

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Aug 14, 2024
@sxyazi
Copy link
Owner

sxyazi commented Aug 15, 2024

Try applying the patch manually not using patch

@sxyazi sxyazi added the waiting on op Waiting for more information from the original poster label Aug 15, 2024
@og900aero
Copy link
Author

Try applying the patch manually not using patch

Now working the log, but doesnt show about Insert key:

2024-08-15T09:46:56.151204Z ERROR yazi::app::app: key: KeyEvent { code: Down, modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) }
    at yazi-fm/src/app/app.rs:86

  2024-08-15T09:47:00.474894Z ERROR yazi::app::app: key: KeyEvent { code: Char('0'), modifiers: KeyModifiers(0x0), kind: Press, state: KeyEventState(0x0) }
    at yazi-fm/src/app/app.rs:86

When press Num Lock, then working Insert/0 key, show 0, see log. When switch to Insert key with Num Lock, doesnt show anythig. But I use lf file manager, then Insert key is working.

@github-actions github-actions bot removed the waiting on op Waiting for more information from the original poster label Aug 15, 2024
@sxyazi
Copy link
Owner

sxyazi commented Aug 15, 2024

In this case I think it's likely a bug of crossterm, because Yazi just receives key events from crossterm as they are without doing any extra processing.

If it doesn't appear in the logs, it means Yazi didn't receive it at all, I don't think there's anything Yazi can do about this.

I suggest you submit an issue to crossterm so that its devs can investigate it further.

@sxyazi sxyazi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2024
@og900aero
Copy link
Author

Come response for your suggestion:
crossterm-rs/crossterm#913
"The events reported in a window environment are different from those reported in a terminal emulator. Using xev creates a window to listen for key events as I understand it. The supported events are often even different in each terminal emulator. For background see https://sw.kovidgoyal.net/kitty/keyboard-protocol/ and http://www.leonerd.org.uk/hacks/fixterms/

You may be able to get this to work in some terminals (but not all) by turning on the keyboard enhancement flags - this would be something that yazi would have to do (and it still may not solve your problem).

You may be able to configure your terminal to do something special with Insert however and then configure yazi to recognize that.

I'm closing this as a duplicate of crossterm-rs/crossterm#685 - you can add a comment there to help track this, but given this is in the keys not really supported by default you might be out of luck for really doing anything useful."

@sxyazi
Copy link
Owner

sxyazi commented Aug 22, 2024

You may be able to get this to work in some terminals (but not all) by turning on the keyboard enhancement flags - this would be something that yazi would have to do (and it still may not solve your problem).

Does your st support the Kitty keyboard extension protocol? If the terminal supports it, Yazi will automatically enable it.

@og900aero
Copy link
Author

You may be able to get this to work in some terminals (but not all) by turning on the keyboard enhancement flags - this would be something that yazi would have to do (and it still may not solve your problem).

Does your st support the Kitty keyboard extension protocol? If the terminal supports it, Yazi will automatically enable it.

I saw that, but couldnt find information from it. I think doesnt support, because the st's philosophy is be simple and small. So I tried Alacritty, and Insert is worked. So, this function doesnt work my best terminal :( Thx for your help.

Copy link

I'm going to lock this issue because it has been closed for 30 days. ⏳
This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working upstream
Projects
None yet
Development

No branches or pull requests

2 participants