Skip to content

Commit 1395545

Browse files
committed
fix - fix incorrect method name and displaced comment
1 parent ba2ad40 commit 1395545

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

lua/flutter-tools/lsp/init.lua

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ local utils = lazy.require("flutter-tools.utils") ---@module "flutter-tools.util
33
local path = lazy.require("flutter-tools.utils.path") ---@module "flutter-tools.utils.path"
44
local color = lazy.require("flutter-tools.lsp.color") ---@module "flutter-tools.lsp.color"
55
local lsp_utils = lazy.require("flutter-tools.lsp.utils") ---@module "flutter-tools.lsp.utils"
6-
local fvm_utils = lazy.require("flutter-tools.lsp.fvm_utils") ---@module "flutter-tools.lsp.fvm_utils"
76

87
local api = vim.api
98
local lsp = vim.lsp
@@ -168,14 +167,16 @@ end
168167
---@return string?
169168
function M.get_project_root_dir()
170169
local conf = require("flutter-tools.config")
171-
local current_buffer_path = lsp_utils.current_buffer_path_if_valid()
170+
local current_buffer_path = path.current_buffer_path()
171+
local root_path = lsp_utils.is_valid_path(current_buffer_path) and
172+
path.find_root(conf.root_patterns, current_buffer_path)
172173

173-
if (current_buffer_path == nil) then
174-
local client = lsp_utils.get_dartls_client()
175-
return client and client.config.root_dir or nil
174+
if (root_path ~= nil) then
175+
return root_path
176176
end
177177

178-
return path.find_root(conf.root_patterns, current_buffer_path) or current_buffer_path
178+
local client = lsp_utils.get_dartls_client()
179+
return client and client.config.root_dir or nil
179180
end
180181

181182
-- FIXME: I'm not sure how to correctly wait till a server is ready before
@@ -242,18 +243,6 @@ local function get_server_config(user_config, callback)
242243
config.on_init = function(client, _)
243244
return client.notify("workspace/didChangeConfiguration", { settings = config.settings })
244245
end
245-
-- TODO: flag something such that we only call attach on exit that has been flagged to
246-
-- re attach.
247-
config.on_exit = function()
248-
if not M.pending_reattach then
249-
return
250-
end
251-
M.pending_reattach = false
252-
-- vim.schedule does not work, it executes attach too soon and
253-
-- instead of creating a new client, the lsp implementation tries
254-
-- to use the old, stopped client.
255-
vim.defer_fn(M.attach, 0)
256-
end
257246
callback(config, paths)
258247
end)
259248
end

lua/flutter-tools/lsp/utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ local lazy = require("flutter-tools.lazy")
44

55
local lsp = vim.lsp
66

7+
-- TODO: Remove after compatibility with Neovim=0.9 is dropped
78
local get_clients = vim.fn.has("nvim-0.10") == 1 and lsp.get_clients or lsp.get_active_clients
89
local utils = lazy.require("flutter-tools.utils") ---@module "flutter-tools.utils"
910

1011
M.SERVER_NAME = "dartls"
1112

12-
-- TODO: Remove after compatibility with Neovim=0.9 is dropped
1313

1414
---@param bufnr number?
1515
---@return vim.lsp.Client?

lua/flutter-tools/utils/init.lua

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,4 @@ M.islist = vim.fn.has("nvim-0.10") == 1 and vim.islist or vim.tbl_islist
151151
local flatten = function(t) return vim.iter(t):flatten():totable() end
152152
M.flatten = vim.fn.has("nvim-0.11") == 1 and flatten or vim.tbl_flatten
153153

154-
---@generic T
155-
---@param t T[]
156-
---@param t2 T[]
157-
---@param compare fun(a: T, b: T): boolean
158-
function M.compare(t, t2, compare)
159-
if #t2 ~= #t then return false end
160-
for index, _ in ipairs(t) do
161-
if not compare(t[index], t2[index]) then
162-
return false
163-
end
164-
end
165-
return true
166-
end
167-
168154
return M

0 commit comments

Comments
 (0)