mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 02:38:46 +00:00
feat(scope): fill the range for treesitter scopes
This commit is contained in:
parent
aeec09c541
commit
38ed01b5a2
1 changed files with 16 additions and 0 deletions
|
@ -196,7 +196,23 @@ end
|
|||
local TSScope = setmetatable({}, Scope)
|
||||
TSScope.__index = TSScope
|
||||
|
||||
-- Expand the scope to fill the range of the node
|
||||
function TSScope:fill()
|
||||
local n = self.node
|
||||
local u, _, d = n:range()
|
||||
while n do
|
||||
local uu, _, dd = n:range()
|
||||
if uu == u and dd == d then
|
||||
self.node = n
|
||||
else
|
||||
break
|
||||
end
|
||||
n = n:parent()
|
||||
end
|
||||
end
|
||||
|
||||
function TSScope:fix()
|
||||
self:fill()
|
||||
self.from, _, self.to = self.node:range()
|
||||
self.from, self.to = self.from + 1, self.to + 1
|
||||
self.indent = math.huge
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue