From 586eedce4bb8c3f88ca20e49193f82b8fd6be99e Mon Sep 17 00:00:00 2001 From: windwp Date: Tue, 20 Apr 2021 15:52:30 +0700 Subject: [PATCH] add log utils --- lua/nvim-ts-autotag/utils.lua | 10 ++++++++++ tests/renametag_spec.lua | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/nvim-ts-autotag/utils.lua b/lua/nvim-ts-autotag/utils.lua index bf35126..74d9311 100644 --- a/lua/nvim-ts-autotag/utils.lua +++ b/lua/nvim-ts-autotag/utils.lua @@ -1,4 +1,5 @@ local _, ts_utils = pcall(require, 'nvim-treesitter.ts_utils') +local log = require('nvim-ts-autotag._log') local M={} M.dump_node = function(node) @@ -17,4 +18,13 @@ M.is_close_empty_node = function(node) return tag_name:match("%<%/%>$") end + +M.dump_node_text = function(target) + for node in target:iter_children() do + local node_type = node:type() + local text = ts_utils.get_node_text(node) + log.debug("type:" .. node_type .. " ") + log.debug(text) + end +end return M diff --git a/tests/renametag_spec.lua b/tests/renametag_spec.lua index b0f3897..fcee203 100644 --- a/tests/renametag_spec.lua +++ b/tests/renametag_spec.lua @@ -1,5 +1,7 @@ local ts = require 'nvim-treesitter.configs' +local log=require('nvim-ts-autotag._log') + if not _G.test_rename then return end @@ -218,6 +220,7 @@ local function Test(test_data) -- autotag.renameTag() helpers.feed(value.key, 'x') helpers.feed("",'x') + vim.wait(10) local result = vim.fn.getline(pos_before.linenr) eq(after, result , "\n\n ERROR: " .. value.name .. "\n") else @@ -228,6 +231,6 @@ local function Test(test_data) end describe('[rename tag]', function() - Test(run_data) + Test(run_data) end)