Skip to content

Files

Latest commit

9fb82e1 · Mar 3, 2025

History

History

decorator-sample

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
May 29, 2020
Jun 27, 2024
Nov 5, 2015
Oct 29, 2018
Dec 29, 2018
May 20, 2022
Nov 27, 2024
Mar 3, 2025
Mar 3, 2025
Oct 28, 2018
Feb 28, 2022

Decorator Sample

This folder contains a sample VS code extension that demonstrates the editor decorator API.

The sample creates a decoration for each number that appears in the active editor. It demonstrates some of the decorator features such as borders, background colors, cursors and hovers.

The sample also shows the use of a user defined themeable color. Instead of hardcoding a color value this allows users (and themes) to redefine the color in the user settings.

sample

VSCode API

The sample code show the usage of the vscode.TextEditor.setDecorations and vscode.window.createTextEditorDecorationType APIs as well as the colors contribution point.

Running the Sample

  • npm install to initialize the project
  • npm run watch to start the compiler in watch mode
  • open this folder in VS Code and press F5
  • this will open the [Extension Development Host] window, running the extension:
    • Open any document that contains single and multi-digit numbers.
    • The extension will decorate single and multiple-digit numbers as shown in the screenshot above.
    • In the user settings, add
      "workbench.colorCustomizations": {
          "myextension.largeNumberBackground": "#ff00ff"
      }
      
      to customize the large number decoration color.