From 9ad47c65bd0b939173803c8a23c9cf0dc6cff70f Mon Sep 17 00:00:00 2001 From: Kristijan Husak Date: Fri, 9 Oct 2020 19:51:27 +0200 Subject: Use utils get_node_text to get line content and trim all whitespaces. --- lua/nvim-treesitter.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lua/nvim-treesitter.lua') diff --git a/lua/nvim-treesitter.lua b/lua/nvim-treesitter.lua index 1eb5276f2..cd1b68509 100644 --- a/lua/nvim-treesitter.lua +++ b/lua/nvim-treesitter.lua @@ -37,15 +37,14 @@ local get_line_for_node = function(node, type_patterns, transform_fn) end end if not is_valid then return '' end - local range = {node:range()} - local line = transform_fn(vim.trim(vim.fn.getline(range[1] + 1))) + local line = transform_fn(vim.trim(ts_utils.get_node_text(node)[1] or '')) -- Escape % to avoid statusline to evaluate content as expression return line:gsub('%%', '%%%%') end -- Trim spaces and opening brackets from end local transform_line = function(line) - return line:gsub('[%[%(%{]*%s*$', '') + return line:gsub('%s*[%[%(%{]*%s*$', '') end function M.statusline(opts) -- cgit v1.2.3-70-g09d2