@@ -41,16 +41,14 @@ defmodule ElixirLS.LanguageServer.Providers.Formatting do
41
41
# If in an umbrella project, the cwd might be set to a sub-app if it's being compiled. This is
42
42
# fine if the file we're trying to format is in that app. Otherwise, we return an error.
43
43
defp can_format? ( file_uri , project_dir ) do
44
- project_dir = project_dir |> String . downcase ( )
45
- file_path = file_uri |> SourceFile . path_from_uri ( ) |> String . downcase ( )
46
- cwd = File . cwd! ( ) |> String . downcase ( )
44
+ file_path = file_uri |> SourceFile . path_from_uri ( ) |> Path . absname ( )
47
45
48
46
not String . starts_with? ( file_path , project_dir ) or
49
- String . starts_with? ( Path . absname ( file_path ) , cwd )
47
+ String . starts_with? ( file_path , File . cwd! ( ) )
50
48
end
51
49
52
50
def should_format? ( file_uri , project_dir , inputs ) when is_list ( inputs ) do
53
- file = String . trim_leading ( file_uri , "file://" )
51
+ file_path = file_uri |> SourceFile . path_from_uri ( ) |> Path . absname ( )
54
52
55
53
inputs
56
54
|> Stream . flat_map ( fn glob ->
@@ -60,7 +58,7 @@ defmodule ElixirLS.LanguageServer.Providers.Formatting do
60
58
]
61
59
end )
62
60
|> Stream . flat_map ( & Path . wildcard ( & 1 , match_dot: true ) )
63
- |> Enum . any? ( & ( file == & 1 ) )
61
+ |> Enum . any? ( & ( file_path == & 1 ) )
64
62
end
65
63
66
64
def should_format? ( _file_uri , _project_dir , _inputs ) , do: true
0 commit comments