visual-studio-codevscode-extensionsgitlens

How to add background text with a VS Code extension like GitLens?


I'm trying to add background text for an extension I'm creating like how GitLens does. Is there an API, or function I can use to push text onto the editor?

enter image description here


Solution

  • I believe the related source code is here: https://github.com/gitkraken/vscode-gitlens/blob/main/src/annotations/lineAnnotationController.ts.

    It uses the decorations feature of the VS Code API- in particular, text editor decorations. See the window.createTextEditorDecorationType and editor.setDecorations and related functions, and DecorationOptions, and its properties like hoverMessage and renderOptions.