From b8f7e971672aea04b754b70feb53b0bc71901a7c Mon Sep 17 00:00:00 2001 From: gnudad Date: Thu, 25 Jul 2024 14:24:51 -0400 Subject: [PATCH] Fix inner pyTripleQuotes only selecting first string_content node of f-string --- lua/various-textobjs/charwise-textobjs.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/various-textobjs/charwise-textobjs.lua b/lua/various-textobjs/charwise-textobjs.lua index d08daa4..29fe08e 100644 --- a/lua/various-textobjs/charwise-textobjs.lua +++ b/lua/various-textobjs/charwise-textobjs.lua @@ -434,12 +434,16 @@ function M.pyTripleQuotes(scope) local text = u.getNodeText(strNode) local isMultiline = text:find("[\r\n]") - -- select `string_content` node, which is the inner docstring - if scope == "inner" then strNode = strNode:child(1) end - ---@cast strNode TSNode local startRow, startCol, endRow, endCol = vim.treesitter.get_node_range(strNode) + if scope == "inner" then + local startNode = strNode:child(1) or strNode + local endNode = strNode:child(strNode:child_count() - 2) or strNode + startRow, startCol, _, _ = vim.treesitter.get_node_range(startNode) + _, _, endRow, endCol = vim.treesitter.get_node_range(endNode) + end + -- fix various off-by-ones startRow = startRow + 1 endRow = endRow + 1