You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thew newer 2.2 api version adds a new Path class https://marta.sh/api/marta/path.type/ that's supposed to be Equatable, so I thought identical path would compare to each other.
But then this plugin fails (open a few identical tabs and run Tab: Path comparison bug command - in 2.1 it will show a popup that there are identical tabs, in 2.2 it will fail and show a popup that no identical paths are found)
Maybe I misunderstand all this equatable stuff, but I thought if I store a path in a different var and later compare via == to the same path from another tab, it should be the same since it's supposed to compare rawValues due to Implements _eq, comparing rawValues.
marta.expose()
marta.plugin({id="bug", name="path comparison bug", apiVersion="2.1"})
marta.action({id="id_tab_pathcomp21", name="Tab: Path comparison bug 2.1"
,apply=function(ctxA) tabPathComparison({ctxA=ctxA}); end})
localstd= {}
-- Print contents of `tbl`, with indentation `indent`, to stringfunctionstd.t2str(tbl, indent, out)
ifnotindentthenindent=0endifnotoutthenout='' endfork, vinpairs(tbl) dokey=string.rep("",indent)..k..": "iftype(v) =="table" thenout=out..key..'\n'; out=std.t2str(v,indent+1,out)
elseiftype(v) =="boolean" thenout=out..key..tostring(v)..'\n'elseiftype(v) =="string" thenout=out..key..v..'\n'elseout=out..key..tostring(v)..'\n' endendreturnoutendfunctiontabPathComparison(arg)
localctxA=arg.ctxAlocalctxW=ctxA.windowlocaltabMan=ctxW.tabslocalpaneMan=ctxW.paneslocaltabA=paneMan.activePanelocaltabPos=tabMan:getPosition(tabA) -- Get the tab position --(tab:PaneContext):Option<TabPosition>localtabCount=tabMan:getCount (tabPos ) -- tab count for a given position --(pos: Option<TabPosition>):Intlocali=0print("tabCount = "..tabCount)
localprev=nillocaldupe=falselocalpath_list= {}
while (i<tabCount) dolocaltab=tabMan:getTab(tabPos, i)
↓ this fails
localpath=tab.model.folder.path-- FAILS
replacing ↑ with ↓ succeeds since we store strings, but I thought Implements _eq, comparing rawValues should do the same when we don't do the conversion and use == directly on paths?
-- local path = tab.model.folder.path.rawValue -- WORKS
if (path==prev) thenmartax.alert("DUPE path" ..tostring(i)..tostring(path))
dupe=trueendpath_list[i] =pathprev=pathi=i+1endifnotdupethenmartax.alert("NO dupes in paths" ..std.t2str(path_list))
endend
The text was updated successfully, but these errors were encountered:
Thew newer 2.2 api version adds a new
Path
class https://marta.sh/api/marta/path.type/ that's supposed to beEquatable
, so I thought identical path would compare to each other.But then this plugin fails (open a few identical tabs and run
Tab: Path comparison bug
command - in 2.1 it will show a popup that there are identical tabs, in 2.2 it will fail and show a popup that no identical paths are found)Maybe I misunderstand all this equatable stuff, but I thought if I store a
path
in a different var and later compare via==
to the same path from another tab, it should be the same since it's supposed to comparerawValues
due toImplements _eq, comparing rawValues.
↓ this fails
replacing ↑ with ↓ succeeds since we store strings, but I thought
Implements _eq, comparing rawValues
should do the same when we don't do the conversion and use==
directly onpath
s?-- local path = tab.model.folder.path.rawValue -- WORKS
The text was updated successfully, but these errors were encountered: