Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 98698

Can a `DocumentFormattingEditProvider` distinguish between a manual `Format Document` command and a `Format on Save` event?

$
0
0

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.


Viewing all articles
Browse latest Browse all 98698

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>