Skip to content

Commit

Permalink
update emit strings
Browse files Browse the repository at this point in the history
  • Loading branch information
MLFlexer committed Jul 23, 2024
1 parent 99e8d10 commit 289dc5d
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions plugin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ end
---@return action_callback
local function workspace_switcher(extra_args)
return wezterm.action_callback(function(window, pane)
wezterm.emit("smart_workspace_switcher.workspace_switcher.start", window)
local workspaces = get_zoxide_workspaces(extra_args)

window:perform_action(
act.InputSelector({
action = wezterm.action_callback(function(inner_window, inner_pane, id, label)
if not id and not label then -- do nothing
else
if id and label then
wezterm.emit("smart_workspace_switcher.workspace_switcher.selected", window, id, label)
local fullPath = string.gsub(label, "^~", wezterm.home_dir)
if fullPath:sub(1, 1) == "/" or fullPath:sub(3, 3) == "\\" then
-- if path is choosen
Expand All @@ -80,6 +81,16 @@ local function workspace_switcher(extra_args)
}),
inner_pane
)
for _, mux_win in ipairs(wezterm.mux.all_windows()) do
if mux_win:get_workspace() == label then
wezterm.emit(
"smart_workspace_switcher.workspace_switcher.created",
mux_win,
id,
label
)
end
end
-- increment path score
run_child_process(zoxide_path .. " add " .. fullPath)
else
Expand All @@ -90,8 +101,17 @@ local function workspace_switcher(extra_args)
}),
inner_pane
)
for _, mux_win in ipairs(wezterm.mux.all_windows()) do
if mux_win:get_workspace() == label then
wezterm.emit(
"smart_workspace_switcher.workspace_switcher.chosen",
mux_win,
id,
label
)
end
end
end
wezterm.emit("smart_workspace_switcher.workspace_chosen", window, id)
end
end),
title = "Choose Workspace",
Expand Down

0 comments on commit 289dc5d

Please sign in to comment.