Skip to content

Commit

Permalink
Add message for when file is ignored.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Oct 16, 2021
1 parent f7f392a commit baa8980
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/FsAutoComplete/FsAutoComplete.Lsp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,10 @@ type FSharpLspServer(backgroundServiceEnabled: bool, state: State, lspClient: FS
{ Start = zero; End = fcsPosToLsp lastPos }

return LspResult.success(Some([| { Range = range; NewText = formatted } |]))
| Ok (FormatDocumentResponse.UnChanged | FormatDocumentResponse.Ignored) ->
| Ok FormatDocumentResponse.Ignored ->
do! lspClient.WindowShowMessage { Type = MessageType.Info; Message = (sprintf "\"%A\" is ignored by a .fantomasignore file." fileName) }

This comment has been minimized.

Copy link
@baronfel

baronfel Oct 16, 2021

Contributor

I have a concern here about triggering this on the same file repeatedly. I could see this getting really annoying as a user, maybe some kind of fantomas-daemon-held list of file paths that have been alerted on? Especially if it was coupled with a user-action to 'don't remind me again'.

This comment has been minimized.

Copy link
@nojaf

nojaf Oct 17, 2021

Author Contributor

Well, I'm not a fan of storing this information in Fantomas.Client as I'd like the individual format request to be stateless.
I also feel like sending the toast is just a reaction of the editor in this case.
Fantomas just tells you the file is ignored, how editors want to deal with this is up to them.
Plus this removes to need to start watching ignore files on Fantomas side.

That being said, it seems unlikely that you would format a file you earlier added to an ignore file.
In the current state, Fantomas would format that file anyway as that check does not happen in CodeFormatter today.

I can remove the WindowShowMessage if you want or we deal with this the moment the UX problem is reported by a user.

return LspResult.success None
| Ok FormatDocumentResponse.UnChanged ->
return LspResult.success None
| Ok FormatDocumentResponse.ToolNotPresent ->
let actions =
Expand Down

0 comments on commit baa8980

Please sign in to comment.