diff --git a/src/CodeFormatter.cs b/src/CodeFormatter.cs index ec2ddd9549..f073f44d9a 100644 --- a/src/CodeFormatter.cs +++ b/src/CodeFormatter.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; +using System.IO; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -197,7 +198,7 @@ private static Workspace OpenFolderWorkspace(string workspacePath, SourceFileMat addedFilePaths.Add(document.FilePath); var isFileIncluded = formatOptions.WorkspaceType == WorkspaceType.Folder || - formatOptions.FileMatcher.Match(document.FilePath).HasMatches; + (formatOptions.FileMatcher.Match(document.FilePath).HasMatches && File.Exists(document.FilePath)); if (!isFileIncluded || !document.SupportsSyntaxTree) { continue;