Skip to content

Commit 9faa5cb

Browse files
committed
Fix textDocument/formatting returns [] when format Ecto migration script
When try to format Ecto migration script that generate project from Phoenix, it will returns inputs "*.exs". But the glob list just detect it only the root of project and apps directory which for umbrella project. This cause make migration script won't match any glob pattern. This changes fixes by add directory of file that want to format to the end of glob list. Fixes #361
1 parent 3a94455 commit 9faa5cb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

apps/language_server/lib/language_server/providers/formatting.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,16 @@ defmodule ElixirLS.LanguageServer.Providers.Formatting do
5454

5555
inputs
5656
|> Stream.flat_map(fn glob ->
57-
[
57+
globs = [
5858
Path.join([project_dir, glob]),
5959
Path.join([project_dir, "apps", "*", glob])
6060
]
61+
62+
if String.starts_with?(file, project_dir) do
63+
globs ++ [Path.join([Path.dirname(file), glob])]
64+
else
65+
globs
66+
end
6167
end)
6268
|> Stream.flat_map(&Path.wildcard(&1, match_dot: true))
6369
|> Enum.any?(&(file == &1))

0 commit comments

Comments
 (0)