Lets take this example into account.
I have a file with contents:
1: one
2: two
3: three
and I create a line decoration for line "two":
const position = new vscode.Position(1, 0);
const range = new vscode.Range(position, position);
const decoration = vscode.window.createTextEditorDecorationType({
gutterIconPath: context.asAbsolutePath('images/icon.svg')
});
vscode.window.activeTextEditor?.setDecorations(decoration, [range]);
that gives me
1: one
* 2: two
3: three
Next step:
I am changing file contents by adding a new line before line "two".
After that file looks like this:
1: one
2:
* 3: two
4: three
As you can see VSCode has updated my line decoration and now it is positioned on line 3 (instead of 2) which is totally correct and I've expected that.
And now the question:
how can I get this current updated position of my line decoration?
If I hold the range reference - it is still pointing to line 2.
What is the right way to handle this decoration changes?
Either of these 2 options would satisfy me:
- a way to query all the current decoration positions displayed for currently open file
- a way to subscribe to
decoration/rangechanges so that I can handle those manually.
Maybe I am totally wrong and it should be done in another way.
Please advise!