diff --git a/apps/language_server/lib/language_server/mix_tasks/format.ex b/apps/language_server/lib/language_server/mix_tasks/format.ex index c7c45bfe5..00df7656d 100644 --- a/apps/language_server/lib/language_server/mix_tasks/format.ex +++ b/apps/language_server/lib/language_server/mix_tasks/format.ex @@ -608,8 +608,15 @@ defmodule Mix.Tasks.ElixirLSFormat do defp recur_formatter_opts_for_file(file, {formatter_opts, subs}) do Enum.find_value(subs, formatter_opts, fn {sub, formatter_opts_and_subs} -> - if String.starts_with?(file, sub) do - recur_formatter_opts_for_file(file, formatter_opts_and_subs) + size = byte_size(sub) + + case file do + <> + when prefix == sub and dir_separator in [?\\, ?/] -> + recur_formatter_opts_for_file(file, formatter_opts_and_subs) + + _ -> + nil end end) end