Closed michaelbrusegard closed 1 month ago
Are you sure? I have tested it, and it seems like it is emitting the event even when creating a new workspace?
https://github.com/user-attachments/assets/6d1b0429-edef-43e3-95bf-3159e778287d
When I move to a workspace the event is emitted which updates the tab bar, as seen in the clip. So the tab bar changes back to normal when exiting. But when I create a new workspace visual-computing-fundamentals
It does not change back to normal as expected. I would suspect this is an issue with the event, but for all I know it could also be an issue that wezterm is unable to process events when switching to a workspace. What do you think?
Do you depend on the Window to change the tabbar? I've previously had problems with the wrong window being emitted when changing workspaces.
The components depend on the window yes. But since the finish event also provides a window object, it uses that if it can
The components depend on the window yes. But since the finish event also provides a window object, it uses that if it can
So because of complications with the window dependencies, I have replaced the finished
event with canceled
.
To check if the fuzzy finder has closed then the canceled
, choosen
and created
event can be used.
To check if the fuzzy finder has started, the start
event can be used
Ok I understand. I will modify the tabline extension API to support multiple events for showing/hiding. Thank you for the clarification
@MLFlexer I am still having issues after implementing with the new events. See: https://github.com/michaelbrusegard/tabline.wez/pull/10.
Regarding the Window
object, I have tried commenting out the code that uses the object provided by smart_workspace_switcher
but the issue still remains
03:12:22.056 ERROR wezterm_gui::overlay::selector > while processing user-defined-25 event: runtime error: ...stablinesDswez/plugin/tabline/components/window/mode.lua:3: attempt to call a nil value (method 'active_key_table')
stack traceback:
...stablinesDswez/plugin/tabline/components/window/mode.lua:3: in function 'tabline.components.window.mode.update'
...michaelbrusegardsZstablinesDswez/plugin/tabline/util.lua:102: in function 'tabline.util.extract_components'
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:64: in upvalue 'create_sections'
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:135: in function 'tabline.component.set_status'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:11: in upvalue 'set_attributes'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:36: in function <...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:30>
stack traceback:
[C]: in local 'poll'
[string "?"]:4: in function 'wezterm.emit'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:155: in upvalue 'workspace_chosen'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:178: in function <...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:172>
03:13:02.089 ERROR wezterm_gui::overlay::selector > while processing user-defined-25 event: runtime error: ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:136: attempt to call a nil value (method 'set_left_status')
stack traceback:
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:136: in function 'tabline.component.set_status'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:11: in upvalue 'set_attributes'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:36: in function <...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:30>
stack traceback:
[C]: in local 'poll'
[string "?"]:4: in function 'wezterm.emit'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:133: in upvalue 'zoxide_chosen'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:181: in function <...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:172>
03:13:11.948 ERROR wezterm_gui::overlay::selector > while processing user-defined-25 event: runtime error: ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:136: attempt to call a nil value (method 'set_left_status')
stack traceback:
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:136: in function 'tabline.component.set_status'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:11: in upvalue 'set_attributes'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:36: in function <...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:30>
stack traceback:
[C]: in local 'poll'
[string "?"]:4: in function 'wezterm.emit'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:133: in upvalue 'zoxide_chosen'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:181: in function <...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:172>
>
Maybe these error messages help. I got the UI to update by being stricter on the nil checks in regards to obtaining a key table. But based on these errors I dont think that was enough
03:12:22.056 ERROR wezterm_gui::overlay::selector > while processing user-defined-25 event: runtime error: ...stablinesDswez/plugin/tabline/components/window/mode.lua:3: attempt to call a nil value (method 'active_key_table') stack traceback: ...stablinesDswez/plugin/tabline/components/window/mode.lua:3: in function 'tabline.components.window.mode.update' ...michaelbrusegardsZstablinesDswez/plugin/tabline/util.lua:102: in function 'tabline.util.extract_components' ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:64: in upvalue 'create_sections' ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:135: in function 'tabline.component.set_status' ...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:11: in upvalue 'set_attributes' ...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:36: in function <...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:30> stack traceback: [C]: in local 'poll' [string "?"]:4: in function 'wezterm.emit' ...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:155: in upvalue 'workspace_chosen' ...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:178: in function <...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:172> 03:13:02.089 ERROR wezterm_gui::overlay::selector > while processing user-defined-25 event: runtime error: ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:136: attempt to call a nil value (method 'set_left_status') stack traceback: ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:136: in function 'tabline.component.set_status' ...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:11: in upvalue 'set_attributes' ...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:36: in function <...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:30> stack traceback: [C]: in local 'poll' [string "?"]:4: in function 'wezterm.emit' ...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:133: in upvalue 'zoxide_chosen' ...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:181: in function <...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:172> 03:13:11.948 ERROR wezterm_gui::overlay::selector > while processing user-defined-25 event: runtime error: ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:136: attempt to call a nil value (method 'set_left_status') stack traceback: ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:136: in function 'tabline.component.set_status' ...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:11: in upvalue 'set_attributes' ...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:36: in function <...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:30> stack traceback: [C]: in local 'poll' [string "?"]:4: in function 'wezterm.emit' ...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:133: in upvalue 'zoxide_chosen' ...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:181: in function <...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:172> >
Maybe these error messages help. I got the UI to update by being stricter on the nil checks in regards to obtaining a key table. But based on these errors I dont think that was enough
There is a difference between a MuxWindow object and a Window or GUIWindow object. It looks like you are trying to call GUI window functions on a MuxWindow, as such you should use the window:gui_window() method on a MuxWindow to get the equivalent GUIWindow, which you can then call these functions on.
Please let me know if that does not work 😄
Are you passing a MUX Window
to the emit events? They expect the GUI Window
object similar to how update-status
works
Yes, I have updated the readme to be fix the update-status
and included a note on the different window objects. Please see commit https://github.com/MLFlexer/smart_workspace_switcher.wezterm/commit/c9b2563a9dac9e862df7b9be4f5dccf254eabbd9 and/or updated sections.
TLDR:
The created
and chosen
events emit MuxWindow objects while the others emit GuiWindow objects. So you have to use window:gui_window() to get the gui window for these events.
https://github.com/michaelbrusegard/tabline.wez/commit/732f58513eaef063d39939aa9987d55d587ee228 I think this should fix the issue regarding mux windows. I still get the same messages in the log though
michaelbrusegard/tabline.wez@732f585 I think this should fix the issue regarding mux windows. I still get the same messages in the log though
Can you paste the logs? Because it seems to emit correctly
stack traceback:
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:21: in upvalue 'create_attributes'
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:134: in function 'tabline.component.set_status'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:19: in upvalue 'set_attributes'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:46: in function <...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:39>
stack traceback:
[C]: in local 'poll'
[string "?"]:4: in function 'wezterm.emit'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:133: in upvalue 'zoxide_chosen'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:181: in function <...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:172>
20:02:28.729 ERROR wezterm_gui::overlay::selector > while processing user-defined-47 event: runtime error: ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:21: attempt to call a nil value (method 'active_key_table')
stack traceback:
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:21: in upvalue 'create_attributes'
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:134: in function 'tabline.component.set_status'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:19: in upvalue 'set_attributes'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:46: in function <...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:39>
stack traceback:
[C]: in local 'poll'
[string "?"]:4: in function 'wezterm.emit'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:155: in upvalue 'workspace_chosen'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:178: in function <...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:172>
20:49:22.203 ERROR wezterm_gui::overlay::selector > while processing user-defined-28 event: runtime error: ...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:21: attempt to call a nil value (method 'active_key_table')
stack traceback:
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:21: in upvalue 'create_attributes'
...elbrusegardsZstablinesDswez/plugin/tabline/component.lua:134: in function 'tabline.component.set_status'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:19: in upvalue 'set_attributes'
...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:46: in function <...elbrusegardsZstablinesDswez/plugin/tabline/extension.lua:39>
stack traceback:
[C]: in local 'poll'
[string "?"]:4: in function 'wezterm.emit'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:155: in upvalue 'workspace_chosen'
...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:178: in function <...xersZssmart_workspace_switchersDswezterm/plugin/init.lua:172>
I have tried to replicate the errors, but I am unable to, it might be because the configuration I am using is wrong:
local tabline = wezterm.plugin.require("https://github.com/michaelbrusegard/tabline.wez")
config.use_fancy_tab_bar = false
tabline.setup({ options = {}, extensions = { "resurrect" } })
If my configuration is wrong, then please send me one that I can try to replicate the error.
tabline.setup({
options = {
theme = 'Catppuccin Mocha',
section_separators = {
left = wezterm.nerdfonts.ple_right_half_circle_thick,
right = wezterm.nerdfonts.ple_left_half_circle_thick,
},
component_separators = {
left = wezterm.nerdfonts.ple_right_half_circle_thin,
right = wezterm.nerdfonts.ple_left_half_circle_thin,
},
tab_separators = {
left = wezterm.nerdfonts.ple_right_half_circle_thick,
right = wezterm.nerdfonts.ple_left_half_circle_thick,
},
},
sections = {
tabline_a = {
{ 'mode', fmt = string.lower },
},
tab_active = {
{ Attribute = { Intensity = 'Bold' } },
{ Foreground = { Color = colors.ansi[6] } },
'tab_index',
'ResetAttributes',
{ Foreground = { Color = colors.foreground } },
{ 'parent', padding = 0 },
'/',
{ Attribute = { Intensity = 'Bold' } },
{ 'cwd', padding = { left = 0, right = 1 } },
{ 'zoomed', padding = 0 },
},
tab_inactive = { 'tab_index', { 'process', icons_only = true, padding = 0 } },
tabline_x = {},
tabline_y = { 'ram', 'cpu' },
},
extensions = {
'resurrect',
'smart_workspace_switcher',
'quick_domains',
},
})
This is my personal configuration where the issue does occur. I think based on the error logs that it comes from one of the modules. Most likely a module that needs access to the window object (this is what I am getting from the error at least).
I think something like this may be a good starting point:
tabline.setup({
sections = {
tabline_a = {
'mode',
'battery',
'cpu',
'ram',
'datetime',
'hostname',
'window',
'workspace',
},
tabline_b = {},
tabline_c = {},
tab_active = {},
tab_inactive = {},
tabline_x = {},
tabline_y = {},
tabline_z = {},
},
extensions = {
'resurrect',
'smart_workspace_switcher',
},
})
I set all the different sections except the one I am testing (a) to an empty table to overwrite the default config that would be applied for the different sections if they were not defined. In tabline_a
I have every component that uses the window object.
Btw the options nil bug should be fixed now, was just an oversight.
I notice that I get the errors with smart_workspace_switcher
but not with quick_domains
or resurrect
now that I am testing. Now the issue may be with tabline.wez
I am not sure
It seems to be a bug within tabline.wez
The correct_window function does not overwrite the window object from the calling function. One way to resolve this behavior is to return and overwrite the window object in the calling function with the newly returned obejct:
local function correct_window(window)
if window then
if window.gui_window then
window = window:gui_window()
end
end
return window -- Newly added line
end
-- ... other code
local function on_hide_event(event, events)
wezterm.on(event, function(window)
window = correct_window(window) -- modified line
if events.delay then
wezterm.time.call_after(events.delay, function()
set_attributes(config.opts.sections, config.normal_mode_colors, window)
end)
else
set_attributes(config.opts.sections, config.normal_mode_colors, window)
end
end)
end
As the title says, the finish event doesnt trigger if I create a new workspace from the fuzzy finder. This is just a minor issue since I rarely create a new workspace, but thought I should report it now that I noticed it