LGUG2Z / komorebi

A tiling window manager for Windows 🍉
https://lgug2z.github.io/komorebi/
Other
9.09k stars 183 forks source link

[BUG]: Toggling float on Neovim Qt causes CLI hang #787

Closed midrare closed 5 months ago

midrare commented 5 months ago

Describe the bug When komorebic toggle-float is used on a Neovim Qt window, komorebi stops responding to komomoreic commands (though it continues managing windows).

To Reproduce Steps to reproduce the behavior:

  1. Open a Neovim Qt window
  2. komorebic toggle-float (works normally)
  3. komorebic toggle-float (bug)
  4. Observe that Neovim Qt is not un-floated.
  5. komorebic state.
  6. Observe that the command never returns. From this point forwards, all komorebic commands are ignored.

Expected behavior komorebic commands continue working like normal.

Operating System

OS Name:                   Microsoft Windows 11 Pro
OS Version:                10.0.22631 N/A Build 22631

komorebic check Output

~> komorebic check                                                                                                                                                                                                                                   1 04/25/2024 03:57:52 PM
No KOMOREBI_CONFIG_HOME detected, defaulting to C:\Users\SHODAN

Looking for configuration files in C:\Users\SHODAN

Found komorebi.json; this file can be passed to the start command with the --config flag

Found C:\Users\SHODAN\.config\whkdrc; key bindings will be loaded from here when whkd is started, and you can start it automatically using the --whkd flag

Additional context

Contents of komorebi.json ```json { "$schema": "https://raw.githubusercontent.com/LGUG2Z/komorebi/v0.1.24/schema.json", "app_specific_configuration_path": "$Env:USERPROFILE/applications.yaml", "window_hiding_behaviour": "Hide", "cross_monitor_move_behaviour": "Insert", "default_workspace_padding": 0, "default_container_padding": 0, "border_width": 0, "border_offset": -1, "active_window_border": false, "active_window_border_colours": { "single": "#42a5f5", "stack": "#00a542", "monocle": "#ff3399" }, "monitors": [ { "workspaces": [ { "name": "I", "layout": "BSP" }, { "name": "II", "layout": "VerticalStack" }, { "name": "III", "layout": "HorizontalStack" } ] }, { "workspaces": [ { "name": "I", "layout": "BSP" }, { "name": "II", "layout": "VerticalStack" }, { "name": "III", "layout": "HorizontalStack" } ] }, ], "mouse_follows_focus": false, "stackbar": { "height": 25, "mode": "OnStack", "tabs": { "width": 220, "focused_text": "#00a542", "unfocused_text": "#b3b3b3", "background": "#141414" } } } ```
LGUG2Z commented 5 months ago

I'm not able to reproduce this on master, it's possible that whatever was causing this bug may have been between v0.1.24 and the latest commit.

Try grabbing and running the artifacts from the latest master build: https://github.com/LGUG2Z/komorebi/actions/runs/8802077150

midrare commented 5 months ago

I tried with latest artifacts but no luck. Also, I forgot to mention I have StartAllBack installed. I uninstalled but this is still occurring.

With more testing this seems unrelated to Neovim. I can induce the bug with any window.

CLI output ~\Downloads\komomorebi\x86_64-pc-windows-msvc\release> ./komorebi 04/25/2024 05:22:37 PM 2024-04-26T00:22:41.688486Z INFO foreground_lock_timeout: komorebi::windows_api: current value of ForegroundLockTimeout is 0 2024-04-26T00:22:41.693035Z INFO komorebi: creating window manager from static configuration file: C:\Users\SHODAN\komorebi.json 2024-04-26T00:22:41.697612Z INFO init: komorebi::window_manager: initialising 2024-04-26T00:22:41.769453Z INFO komorebi::process_command: listening on komorebi.sock 2024-04-26T00:22:45.727322Z INFO process_command{ToggleFloat}:toggle_float:float_window: komorebi::window_manager: floating window 2024-04-26T00:22:45.727463Z INFO process_command{ToggleFloat}:toggle_float:float_window:focus_container{idx=18446744073709551615}: komorebi::workspace: focusing container 2024-04-26T00:22:45.738626Z INFO process_command{ToggleFloat}:toggle_float:update_focused_workspace{follow_focus=false trigger_focus=true}: komorebi::window_manager: updating 2024-04-26T00:22:45.741457Z INFO process_command{ToggleFloat}: komorebi::process_command: processed 2024-04-26T00:22:45.753808Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 66924 })}:update_focused_workspace{follow_focus=false trigger_focus=false}: komorebi::window_manager: updating 2024-04-26T00:22:45.756393Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 66924 })}: komorebi::process_event: processed: (hwnd: 66924, title: [BUG]: Toggling float on Neovim Qt causes CLI hang · Issue #787 · LGUG2Z/komorebi — Mozilla Firefox, exe: firefox.exe, class: MozillaWindowClass) 2024-04-26T00:22:47.273206Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 66820 })}:focus_monitor{idx=1}: komorebi::window_manager: focusing monitor 2024-04-26T00:22:47.273366Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 66820 })}:focus_window{idx=0}: komorebi::container: focusing window 2024-04-26T00:22:47.283989Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 66820 })}:update_focused_workspace{follow_focus=false trigger_focus=false}: komorebi::window_manager: updating 2024-04-26T00:22:47.287160Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 66820 })}:focus_window{idx=0}: komorebi::container: focusing window 2024-04-26T00:22:47.287266Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 66820 })}:focus_container{idx=0}: komorebi::workspace: focusing container 2024-04-26T00:22:47.288115Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 66820 })}: komorebi::process_event: processed: (hwnd: 66820, title: Nushell MSVC, exe: WindowsTerminal.exe, class: CASCADIA_HOSTING_WINDOW_CLASS) 2024-04-26T00:22:50.090398Z INFO process_command{ToggleFloat}:toggle_float:float_window: komorebi::window_manager: floating window 2024-04-26T00:22:50.090547Z INFO process_command{ToggleFloat}:toggle_float:float_window:focus_container{idx=18446744073709551615}: komorebi::workspace: focusing container 2024-04-26T00:22:50.092497Z INFO process_command{ToggleFloat}:toggle_float:update_focused_workspace{follow_focus=false trigger_focus=true}: komorebi::window_manager: updating 2024-04-26T00:22:50.094211Z INFO process_command{ToggleFloat}: komorebi::process_command: processed 2024-04-26T00:22:51.598938Z INFO process_command{ToggleFloat}:toggle_float:unfloat_window: komorebi::window_manager: unfloating window 2024-04-26T00:22:51.599089Z INFO process_command{ToggleFloat}:toggle_float:unfloat_window:focus_window{idx=0}: komorebi::container: focusing window 2024-04-26T00:22:51.599212Z ERROR process_command{ToggleFloat}:toggle_float:unfloat_window: komorebi: panicked at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\library\alloc\src\collections\vec_deque\mod.rs:1767:9: index out of bounds panic.file="/rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04\\library\\alloc\\src\\collections\\vec_deque\\mod.rs" panic.line=1767 panic.column=9
LGUG2Z commented 5 months ago

@raggi had a fix for something that may have been similar with monocle windows here: https://github.com/LGUG2Z/komorebi/commit/efa562de5cc8698088d49936dc45359ca07e0246

However I'm not seeing anything immediately similar in the toggle_float call path 🤔

https://github.com/LGUG2Z/komorebi/blob/3370e6acc55dc57a541819adb282de5134dd9d0c/komorebi/src/window_manager.rs#L1641

LGUG2Z commented 5 months ago

The actual library call that is failing an assertion:

https://github.com/rust-lang/rust/blob/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/alloc/src/collections/vec_deque/mod.rs#L1767

LGUG2Z commented 5 months ago

Which leads me to believe this is the offending call: https://github.com/LGUG2Z/komorebi/blob/master/komorebi/src/workspace.rs#L814

LGUG2Z commented 5 months ago

@midrare Which layout is this happening with and does it matter which position the window is in (ie. first or last)?

LGUG2Z commented 5 months ago

Nevermind, I just reproduced this with the BSP layout when the NeoVim QT window is the only one in the layout!

LGUG2Z commented 5 months ago

https://github.com/LGUG2Z/komorebi/commit/0b04e3ef93beace9ebe4e968c594b2c1dec72de8 should hopefully address your issue 🤞

midrare commented 5 months ago

Tested with artifacts from https://github.com/LGUG2Z/komorebi/actions/runs/8841765357 and all appears to be working. Thanks for the quick fix.