mirror of
https://github.com/folke/snacks.nvim
synced 2025-07-07 21:25:11 +00:00
fix(scope): use rawequal
to check if scope impl is treesitter. Closes #1413
This commit is contained in:
parent
338eed18ac
commit
4ce197bff9
1 changed files with 5 additions and 5 deletions
|
@ -409,7 +409,7 @@ end
|
|||
function TSScope:init(cb, opts)
|
||||
local parser = self:parser(opts)
|
||||
if not parser then
|
||||
return
|
||||
return cb()
|
||||
end
|
||||
if M.TS_ASYNC then
|
||||
parser:parse(opts.treesitter.injections, cb)
|
||||
|
@ -486,7 +486,7 @@ 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",
|
||||
rawequal(meta, TSScope) and "TSScope" or rawequal(meta, IndentScope) and "IndentSCope" or "Scope",
|
||||
self.buf or -1,
|
||||
self.from or -1,
|
||||
self.to or -1,
|
||||
|
@ -513,8 +513,8 @@ function M.get(cb, opts)
|
|||
end
|
||||
|
||||
---@type snacks.scope.Scope
|
||||
local Class = opts.treesitter.enabled and TSScope.has_ts(opts.buf) and TSScope or IndentScope
|
||||
if Class == TSScope and opts.parse ~= false then
|
||||
local Class = (opts.treesitter.enabled and TSScope.has_ts(opts.buf)) and TSScope or IndentScope
|
||||
if rawequal(Class, TSScope) and opts.parse ~= false then
|
||||
TSScope:init(function()
|
||||
opts.parse = false
|
||||
M.get(cb, opts)
|
||||
|
@ -524,7 +524,7 @@ function M.get(cb, opts)
|
|||
local scope = Class:find(opts) --[[ @as snacks.scope.Scope? ]]
|
||||
|
||||
-- fallback to indent based detection
|
||||
if not scope and Class == TSScope then
|
||||
if not scope and rawequal(Class, TSScope) then
|
||||
Class = IndentScope
|
||||
scope = Class:find(opts)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue