better-comments icon indicating copy to clipboard operation
better-comments copied to clipboard

add 'onDidOpenTextDocument' as a trigger for drawing the decorations

Open boltex opened this issue 3 years ago • 1 comments

My user case opens/ creates documents without language set. Some small time later I set a language but the decorator for 'better-comments' has already passed.

onDidOpenTextDocument is triggered by vscode.languages.setTextDocumentLanguage(document, language) so this would be a very good event to listen to to apply the decorators, along with your existing ones.

I'll make the modification and PR soon if you approve of this :)

boltex avatar Aug 07 '22 03:08 boltex

Clarification: there is no decorations initially for the document without any language set, and setting a language manually doesn't trigger the better-comments decoration.

Extensions that call setTextDocumentLanguage will trigger the onDidCloseTextDocument event followed by the onDidOpenTextDocument event. That is why i suggest adding 'onDidOpenTextDocument' as a trigger event for the better-comments decorations.

See https://code.visualstudio.com/api/references/vscode-api#languages.setTextDocumentLanguage

boltex avatar Aug 07 '22 03:08 boltex