Skip to content

Commit 931c0e9

Browse files
authored
fix: modify workspace detection function to prevent the workspace from becoming a directory with a large number of files (#51)
1 parent ad901a6 commit 931c0e9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lua/js-i18n/utils.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ M.Library = {
1010
--- @param bufnr number
1111
--- @return string プロジェクトのルートディレクトリ
1212
function M.get_workspace_root(bufnr)
13-
local root = vim.fs.root(bufnr, "package.json")
13+
-- $HOME になった場合は除外する
14+
local excludes = { vim.env.HOME }
15+
local root = vim.fs.root(bufnr, { "package.json", ".git" })
16+
17+
if root and vim.tbl_contains(excludes, root) then
18+
root = nil
19+
end
20+
1421
if root == nil then
1522
return vim.fn.getcwd()
1623
else

0 commit comments

Comments
 (0)