editor.setDecorations does not render all contentText correctly
Type: Bug
This extension creates a decoration type that displays a “before” text label with a specific foreground and background color. It iterates over a set of characters, generating every possible two-character combination from that set.
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
const labelDecoration = vscode.window.createTextEditorDecorationType({
before: {
color: 'black',
backgroundColor: '#a3be8c',
},
});
const labelDecorationQuestion = vscode.window.createTextEditorDecorationType({
before: {
color: 'black',
backgroundColor: '#ebcb8b',
contentText: '?'
},
});
// Map of label character to target position
let labelMap: Map<string, { editor: vscode.TextEditor, position: vscode.Position }> = new Map();
// Define the character pool for labels: lowercase, then uppercase, then digits
const labelChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+[]{}|;:\'",.<>/`~\\';
const editor = vscode.window.activeTextEditor
const decorationOptions: vscode.DecorationOptions[] = [];
let line = 0;
for (const c1 of labelChars) {
let cnt = 0;
for (const c2 of labelChars) {
decorationOptions.push({
range: new vscode.Range(new vscode.Position(line, cnt), new vscode.Position(line, cnt + 1)),
renderOptions: {
before: { contentText: c1 + c2 }
}
});
cnt += 3;
}
line += 1
}
if (editor) {
editor.setDecorations(labelDecoration, decorationOptions);
}
}
Expected Behavior Each unique pair of characters (c1 + c2) should appear exactly once in the “before” content on its corresponding position.
Actual Behavior
Some lines or columns show repeated decorations, while others skip certain pairs. The console logs confirm each pair is generated distinctly, but in the editor the decorations appear partially duplicated or re‑ordered. Example:
After
bz, I expect the next text to be bA
VS Code version: Code 1.97.2 (e54c774e0add60467559eb0d1e229c6452cf8447, 2025-02-12T23:20:35.343Z) OS version: Linux x64 6.13.5 Modes:
System Info
| Item | Value |
|---|---|
| CPUs | 13th Gen Intel(R) Core(TM) i7-13700K (24 x 5300) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: disabled_software vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: disabled_off webnn: disabled_off |
| Load (avg) | 1, 1, 1 |
| Memory (System) | 31.09GB (15.75GB free) |
| Process Argv | --ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true flash.vscode --crash-reporter-id ac05c1a8-c8ea-496b-8089-200a0791d978 |
| Screen Reader | no |
| VM | 0% |
| DESKTOP_SESSION | undefined |
| XDG_CURRENT_DESKTOP | Hyprland |
| XDG_SESSION_DESKTOP | Hyprland |
| XDG_SESSION_TYPE | wayland |
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc2:31192216
iacca1:31171482
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
8did9651:31230678
hdaa2157:31222309
copilot_t_ci:31222730
jda6j935:31233686
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.98.0. Please try upgrading to the latest version and checking whether this issue remains.
Happy Coding!