I'm authoring a VSCode Formatter Extension; it's little more than a class that extends DocumentFormattingEditProvider
that I'm using to hook into VSCode's native Format Document
and Format On Save
functionality.
I'd like to provide some kind of 'ignore these specific files' behavior (to mirror the behavior of the external tool I'm using to generate edits) such that matching documents ignore all Format on Save
requests. I think it would be useful to allow the tool to still run on matching documents when a user explicitly enters a Format Document
command from the Command Palette. Doing so would require knowing what event generated the formatting request, and only ignoring some of them.
Is there there any way to detect the source of a format request, (Format Document
, Format on Save
, Format on Paste
, etc.) either from within the body of provideDocumentFormattingEdits
or externally through another piece of the extension API?
I've not been able to find anything in the API documentation, or in the state of the running extension (when I drop a breakpoint inside my provideDocumentFormattingEdits
method) that could provide that information.