From 228613899d6d0562c1cd639e69c796fa65c2636d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 11 Mar 2021 21:05:02 +0800 Subject: stash --- script/provider/provider.lua | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'script/provider/provider.lua') diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 917f66cc..bfd51416 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -17,6 +17,7 @@ local fs = require 'bee.filesystem' local lang = require 'language' local plugin = require 'plugin' local progress = require 'progress' +local tm = require 'text-merger' local function updateConfig() local diagnostics = require 'provider.diagnostic' @@ -270,18 +271,8 @@ proto.on('textDocument/didChange', function (params) if not files.isLua(uri) and not files.isOpen(uri) then return end - files.clearDiff(uri) - local text = files.getText(uri) or '' - for _, change in ipairs(changes) do - if change.range then - local start, finish = files.unrange(uri, change.range) - text = text:sub(1, start - 1) .. change.text .. text:sub(finish) - else - text = change.text - end - files.setRawText(uri, text) - end - files.setRawText(uri, '') + log.debug('changes', util.dump(changes)) + local text = tm(uri, changes) files.setText(uri, text, true) end) -- cgit v1.2.3