fix: startswith direction

This commit is contained in:
əlemi 2024-09-26 03:40:25 +02:00
parent b3315dff9b
commit 2d41812e23
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -83,7 +83,7 @@ M.move = function(state, path, extra)
if selected.type == "buffer" then if selected.type == "buffer" then
return vim.ui.input({ prompt = "move content into open buffer?" }, function (input) return vim.ui.input({ prompt = "move content into open buffer?" }, function (input)
if input == nil then return end if input == nil then return end
if not vim.startswith("y", string.lower(input)) then return end if not vim.startswith(string.lower(input), "y") then return end
local window = utils.get_appropriate_window(state) local window = utils.get_appropriate_window(state)
local buf = vim.api.nvim_win_get_buf(window) local buf = vim.api.nvim_win_get_buf(window)
buf_manager.attach(selected.name, buf) buf_manager.attach(selected.name, buf)
@ -97,7 +97,7 @@ M.copy = function(state, path, extra)
if selected.type == "buffer" then if selected.type == "buffer" then
return vim.ui.input({ prompt = "copy content to remote buffer?" }, function (input) return vim.ui.input({ prompt = "copy content to remote buffer?" }, function (input)
if input == nil then return end if input == nil then return end
if not vim.startswith("y", string.lower(input)) then return end if not vim.startswith(string.lower(input), "y") then return end
local window = utils.get_appropriate_window(state) local window = utils.get_appropriate_window(state)
local buf = vim.api.nvim_win_get_buf(window) local buf = vim.api.nvim_win_get_buf(window)
local content = codemp_utils.buffer.get_content(buf) local content = codemp_utils.buffer.get_content(buf)
@ -112,14 +112,14 @@ M.delete = function(state, path, extra)
if selected.type == "root" and vim.startswith(selected.name, "#") then if selected.type == "root" and vim.startswith(selected.name, "#") then
vim.ui.input({ prompt = "disconnect from workspace?" }, function (input) vim.ui.input({ prompt = "disconnect from workspace?" }, function (input)
if input == nil then return end if input == nil then return end
if not vim.startswith("y", string.lower(input)) then return end if not vim.startswith(string.lower(input), "y") then return end
ws_manager.leave() ws_manager.leave()
end) end)
elseif selected.type == "buffer" then elseif selected.type == "buffer" then
if CODEMP.workspace == nil then error("join a workspace first") end if CODEMP.workspace == nil then error("join a workspace first") end
vim.ui.input({ prompt = "delete buffer '" .. selected.name .. "'?" }, function (input) vim.ui.input({ prompt = "delete buffer '" .. selected.name .. "'?" }, function (input)
if input == nil then return end if input == nil then return end
if not vim.startswith("y", string.lower(input)) then return end if not vim.startswith(string.lower(input), "y") then return end
CODEMP.workspace:delete(selected.name):and_then(function () CODEMP.workspace:delete(selected.name):and_then(function ()
print("deleted buffer " .. selected.name) print("deleted buffer " .. selected.name)
manager.refresh("codemp") manager.refresh("codemp")
@ -129,7 +129,7 @@ M.delete = function(state, path, extra)
if CODEMP.client == nil then error("connect to server first") end if CODEMP.client == nil then error("connect to server first") end
vim.ui.input({ prompt = "delete buffer '" .. selected.name .. "'?" }, function (input) vim.ui.input({ prompt = "delete buffer '" .. selected.name .. "'?" }, function (input)
if input == nil then return end if input == nil then return end
if not vim.startswith("y", string.lower(input)) then return end if not vim.startswith(string.lower(input), "y") then return end
CODEMP.client:delete_workspace(selected.name):and_then(function () CODEMP.client:delete_workspace(selected.name):and_then(function ()
print("deleted workspace " .. selected.name) print("deleted workspace " .. selected.name)
manager.refresh("codemp") manager.refresh("codemp")