mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
feat(scope): added __tostring
for debugging
This commit is contained in:
parent
be2779e942
commit
94e0849c3a
1 changed files with 12 additions and 1 deletions
|
@ -115,7 +115,7 @@ Scope.__index = Scope
|
|||
---@param opts snacks.scope.Opts
|
||||
---@return T
|
||||
function Scope:new(scope, opts)
|
||||
local ret = setmetatable(scope, { __index = self, __eq = self.__eq })
|
||||
local ret = setmetatable(scope, { __index = self, __eq = self.__eq, __tostring = self.__tostring })
|
||||
ret.opts = opts
|
||||
return ret
|
||||
end
|
||||
|
@ -369,6 +369,17 @@ function TSScope:parent()
|
|||
return parent and parent ~= self.node:tree():root() and self:with({ node = parent }):root() or nil
|
||||
end
|
||||
|
||||
function Scope:__tostring()
|
||||
local meta = getmetatable(self)
|
||||
return ("%s(buf=%d, from=%d, to=%d, indent=%d)"):format(
|
||||
meta == TSScope and "TSScope" or meta == IndentScope and "IndentSCope" or "Scope",
|
||||
self.buf or -1,
|
||||
self.from or -1,
|
||||
self.to or -1,
|
||||
self.indent or 0
|
||||
)
|
||||
end
|
||||
|
||||
---@param opts? snacks.scope.Opts
|
||||
---@return snacks.scope.Scope?
|
||||
function M.get(opts)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue