Skip to content

Commit

Permalink
fix: inner pyTripleQuotes only selecting first string_content node …
Browse files Browse the repository at this point in the history
…of f-string
  • Loading branch information
gnudad authored and chrisgrieser committed Jul 27, 2024
1 parent 6cc4433 commit 26d174b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lua/various-textobjs/charwise-textobjs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 26d174b

Please sign in to comment.