Skip to content

Commit 6a49a03

Browse files
committed
refactor(marks): fix offset line and move into init.lua
also set node in marks record instead of true
1 parent 078a9e5 commit 6a49a03

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

doc/nvim-tree-lua.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,6 @@ You can toggle marks on files/folders with
12621262
default.
12631263

12641264
To get the list of marked paths, you can call
1265-
`require("nvim-tree.marks").get_marks()`. This will return `{string}`.
1265+
`require("nvim-tree.marks").get_marks()`. This will return `{node}`.
12661266

12671267
vim:tw=78:ts=4:sw=4:et:ft=help:norl:

lua/nvim-tree/marks.lua renamed to lua/nvim-tree/marks/init.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ local NvimTreeMarks = {}
77
local M = {}
88

99
local function add_mark(node)
10-
NvimTreeMarks[node.absolute_path] = true
10+
NvimTreeMarks[node.absolute_path] = node
1111
M.draw()
1212
end
1313

@@ -30,8 +30,8 @@ end
3030

3131
function M.get_marks()
3232
local list = {}
33-
for k in pairs(NvimTreeMarks) do
34-
table.insert(list, k)
33+
for _, node in pairs(NvimTreeMarks) do
34+
table.insert(list, node)
3535
end
3636
return list
3737
end
@@ -51,13 +51,14 @@ function M.draw()
5151
M.clear()
5252

5353
local buf = view.get_bufnr()
54+
local add = core.get_nodes_starting_line() - 1
5455
Iterator.builder(core.get_explorer().nodes)
5556
:recursor(function(node)
5657
return node.open and node.nodes
5758
end)
5859
:applier(function(node, idx)
5960
if M.get_mark(node) then
60-
vim.fn.sign_place(0, GROUP, SIGN_NAME, buf, { lnum = idx + 1, priority = 3 })
61+
vim.fn.sign_place(0, GROUP, SIGN_NAME, buf, { lnum = idx + add, priority = 3 })
6162
end
6263
end)
6364
:iterate()

0 commit comments

Comments
 (0)