mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 07:24:52 +01:00
fix: just ask if overwriting when attaching
to upload content cancel attach and use force share
This commit is contained in:
parent
9e48af37fe
commit
2391b3c4fd
1 changed files with 8 additions and 9 deletions
|
@ -19,16 +19,12 @@ local ticks = {}
|
||||||
---@param opts AttachOptions options for attaching
|
---@param opts AttachOptions options for attaching
|
||||||
local function attach(name, opts)
|
local function attach(name, opts)
|
||||||
if not opts.skip_exists_check and vim.fn.bufexists(name) == 1 then
|
if not opts.skip_exists_check and vim.fn.bufexists(name) == 1 then
|
||||||
vim.ui.select(
|
vim.ui.input(
|
||||||
{ "download content", "upload content" },
|
{ prompt = "buffer exists, overwrite?" },
|
||||||
{ prompt = "buffer is already open" },
|
|
||||||
function (choice)
|
function (choice)
|
||||||
if choice == nil then return end
|
if not vim.startswith(string.lower(choice), "y") then return end
|
||||||
opts.buffer = vim.fn.bufnr(name)
|
opts.buffer = vim.fn.bufnr(name)
|
||||||
opts.skip_exists_check = true
|
opts.skip_exists_check = true
|
||||||
if choice == "upload content" then
|
|
||||||
opts.content = utils.buffer.get_content(opts.buffer)
|
|
||||||
end
|
|
||||||
attach(name, opts)
|
attach(name, opts)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
@ -168,9 +164,12 @@ local function detach(name)
|
||||||
local buffer = buffer_id_map[name]
|
local buffer = buffer_id_map[name]
|
||||||
id_buffer_map[buffer] = nil
|
id_buffer_map[buffer] = nil
|
||||||
buffer_id_map[name] = nil
|
buffer_id_map[name] = nil
|
||||||
CODEMP.workspace:detach(name)
|
if not CODEMP.workspace:detach(name) then
|
||||||
|
print(" /!\\ dangling reference, detach incomplete")
|
||||||
|
else
|
||||||
|
print(" -- detached from buffer " .. name)
|
||||||
|
end
|
||||||
|
|
||||||
print(" -- detached from buffer " .. name)
|
|
||||||
require('codemp.window').update()
|
require('codemp.window').update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue