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

refactor: reenable the opt-in --client-id flag for yazi #229

Merged
merged 1 commit into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/yazi/process/legacy_events_from_file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function LegacyEventReadingFromEventFile:new(config)
end

---@param path Path
function LegacyEventReadingFromEventFile:get_yazi_command(path, _)
function LegacyEventReadingFromEventFile:get_yazi_command(path)
return string.format(
'yazi %s --local-events "rename,delete,trash,move,cd" --chooser-file "%s" > "%s"',
vim.fn.shellescape(path.filename),
Expand Down
32 changes: 21 additions & 11 deletions lua/yazi/process/ya_process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local highlight_hovered_buffer =
---@field public events YaziEvent[] "The events that have been received from yazi"
---@field public new fun(config: YaziConfig, yazi_id: string): YaProcess
---@field private config YaziConfig
---@field private yazi_id string
---@field private yazi_id? string "The YAZI_ID of the yazi process. Can be nil if this feature is not in use."
---@field private ya_process vim.SystemObj
---@field private retries integer
local YaProcess = {}
Expand All @@ -22,7 +22,11 @@ YaProcess.__index = YaProcess
---@param yazi_id string
function YaProcess.new(config, yazi_id)
local self = setmetatable({}, YaProcess)
self.yazi_id = yazi_id

if config.use_yazi_client_id_flag == true then
self.yazi_id = yazi_id
end

self.config = config
self.events = {}
self.retries = 0
Expand All @@ -31,15 +35,21 @@ function YaProcess.new(config, yazi_id)
end

---@param path Path
---@param yazi_id string
---@diagnostic disable-next-line: unused-local
-- selene: allow(unused_variable)
function YaProcess:get_yazi_command(path, yazi_id)
return string.format(
'yazi %s --chooser-file "%s"',
vim.fn.shellescape(path.filename),
self.config.chosen_file_path
)
function YaProcess:get_yazi_command(path)
if self.yazi_id then
return string.format(
'yazi %s --chooser-file "%s" --client-id "%s"',
vim.fn.shellescape(path.filename),
self.config.chosen_file_path,
self.yazi_id
)
else
return string.format(
'yazi %s --chooser-file "%s"',
vim.fn.shellescape(path.filename),
self.config.chosen_file_path
)
end
end

function YaProcess:kill()
Expand Down
2 changes: 1 addition & 1 deletion lua/yazi/yazi_process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function YaziProcess:start(config, path, on_exit)
and YaProcess.new(config, yazi_id)
or LegacyEventReadingFromEventFile:new(config)

local yazi_cmd = self.event_reader:get_yazi_command(path, yazi_id)
local yazi_cmd = self.event_reader:get_yazi_command(path)
Log:debug(string.format('Opening yazi with the command: (%s).', yazi_cmd))

self.yazi_job_id = vim.fn.termopen(yazi_cmd, {
Expand Down
Loading