Skip to content

Commit

Permalink
fix: ext.tsnode now does not detect in node half char before node
Browse files Browse the repository at this point in the history
  • Loading branch information
altermo committed Aug 31, 2023
1 parent e2a0912 commit 667d230
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lua/ultimate-autopair/extension/tsnode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ local M={}
M.savetype={}
---@param o core.o
---@param nodetypes string[]
---@param incheck? boolean
---@return TSNode?
function M._in_tsnode(o,nodetypes)
function M._in_tsnode(o,nodetypes,incheck)
local ssave=o.save[M._in_tsnode] or {} o.save[M._in_tsnode]=ssave
local save=ssave[nodetypes] or {} ssave[nodetypes]=save
if incheck then save={} end
local node=utils.gettsnode(o)
if node and save[node:id()] then return unpack(save[node:id()]) end
local function fn(n)
local _,startcol,_=n:start()
return startcol+1==o.col+o._coloffset(o.col,o.row)
end
local ql={}
local cache={}
local nsave=M.get_save(o)
Expand All @@ -34,7 +32,7 @@ function M._in_tsnode(o,nodetypes)
ql[v]=true
end
end
while node and ((not ql[node:type()]) or fn(node)) do
while node and (not ql[node:type()] or (incheck and ({node:start()})[2]==o.col-1)) do
if node then save[node:id()]=cache end
node=node:parent()
--TODO fix: TSNode:id() doesn't differ between trees
Expand All @@ -61,7 +59,7 @@ end
---@param save ext.tsnode.save
---@param m prof.def.module
function M.set_in_node(o,conf,save,m)
local node=M._in_tsnode(o,default.orof(conf.separate,o,m,true))
local node=M._in_tsnode(o,default.orof(conf.separate,o,m,true),true)
if node then
local srow,scol,erow,ecol=utils.gettsnodepos(node,o)
save.scol=scol
Expand Down

0 comments on commit 667d230

Please sign in to comment.