From 372ef9b32053c82f15bf84608497702638deb786 Mon Sep 17 00:00:00 2001 From: Lukasz Samson Date: Thu, 28 Sep 2023 22:02:38 +0200 Subject: [PATCH] Apply upstream fix for https://github.com/elixir-lang/elixir/issues/12969 Fixes https://github.com/elixir-lsp/elixir-ls/issues/992 --- .../lib/language_server/mix_tasks/format.ex | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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