Skip to content

Commit

Permalink
Fix logic to relativise to ignorefile location
Browse files Browse the repository at this point in the history
  • Loading branch information
Smaug123 committed Mar 26, 2022
1 parent 0d14a80 commit 11ae382
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Fantomas.Extras/IgnoreFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,11 @@ module IgnoreFile =

let private relativePathPrefix = sprintf ".%c" Path.DirectorySeparatorChar

let private removeRelativePathPrefix (path: string) =
if path.StartsWith(relativePathPrefix) then
path.Substring(2)
else
path

/// When executed from the command line, Fantomas will not dynamically locate
/// the most appropriate `.fantomasignore` for each input file; it only finds
/// a single `.fantomasignore` file. This is that file.
let current: Lazy<IgnoreFile option> = lazy find System.Environment.CurrentDirectory
let current: Lazy<IgnoreFile option> =
lazy find (Path.Combine(System.Environment.CurrentDirectory, "_"))

let isIgnoredFile (ignoreFile: IgnoreFile option) (file: string) : bool =
match ignoreFile with
Expand All @@ -55,7 +50,12 @@ module IgnoreFile =
let fullPath = Path.GetFullPath(file)

try
let path = removeRelativePathPrefix fullPath
let path =
if fullPath.StartsWith ignoreFile.Location.Directory.FullName then
fullPath.[ignoreFile.Location.Directory.FullName.Length + 1 ..]
else
fullPath

ignoreFile.IgnoreList.IsIgnored(path, false)
with
| ex ->
Expand Down

0 comments on commit 11ae382

Please sign in to comment.