From f69d91b9f632d531411cb4190d824e346a460c07 Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 17 Nov 2023 03:44:57 +0100 Subject: [PATCH] fix: insert at index 0, locked dep --- Cargo.toml | 2 +- src/codemp.lua | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0929874..4a2b82a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -codemp = { git = "ssh://git@github.com/codewithotherpeopleandchangenamelater/codemp.git", branch = "woot", features = ["global", "sync"] } +codemp = { git = "ssh://git@github.com/codewithotherpeopleandchangenamelater/codemp.git", rev = "486999bc31b8a925d56ee6d3747b06fcd97b00d5", features = ["global", "sync"] } mlua = { version = "0.9.0", features = ["module", "luajit"] } thiserror = "1.0.47" derive_more = "0.99.17" diff --git a/src/codemp.lua b/src/codemp.lua index e704537..d871bad 100644 --- a/src/codemp.lua +++ b/src/codemp.lua @@ -197,6 +197,7 @@ vim.api.nvim_create_user_command( if tick <= codemp_changed_tick then return end local start = vim.api.nvim_buf_get_offset(buf, firstline) local content = table.concat(vim.api.nvim_buf_get_lines(buf, firstline, new_lastline, false), '\n') + if start == -1 then start = 0 end if new_lastline < lastline then old_byte_size = old_byte_size + 1 end controller:send(start, start + old_byte_size - 1, content) end @@ -206,16 +207,6 @@ vim.api.nvim_create_user_command( register_controller_handler(args.args, controller, function(event) codemp_changed_tick = vim.api.nvim_buf_get_changedtick(buffer) + 1 buffer_set_content(buffer, event.content) - -- local start_row = vim.api.nvim_buf_get_offset(buffer, event.first) - -- local end_row = vim.api.nvim_buf_get_offset(buffer, event.last - 1) - -- vim.api.nvim_buf_set_text( - -- buffer, - -- start_row, - -- event.first - start_row, - -- end_row, - -- event.last - end_row, - -- vim.fn.split(event.content, '\n', true) - -- ) end) print(" ++ joined workspace " .. args.args)