New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove decoration type #22
Comments
A |
@jrieken even calling dispose on the decoration type object the style is not removed from the editor. In the decorator app, a border is added around the numbers. How can I remove those borders? The editor has a method called obs: I am trying to create an extension that adds a decorator and removes it when a rule is matched. |
Hm, @alexandrudima is the expert but try calling it with an empty array. That should tell the editor to not show decorations of that type anymore. |
I tried the approach suggested but it doesn't remove the style, here goes a snippet to illustrate what I've done:
But it didn't work. I found an extension that has a method called https://github.com/hoovercj/vscode-dimmer/blob/master/src/extension.ts |
Sorry, but my knowledge is exhausted. @aeschli or @alexandrudima are you folks, tho both are current on vacation so be a little patient. |
This issue hasn't been answered in a proper way, do I need to open a new one? Or just wait for @aeschli / @alexandrudima |
Both are out on vaccation 🌴 so please be patient |
@marabesi both answers from @jrieken are correct:
Most issues I've seen in code that uses this API are around using the wrong instance of |
@alexandrudima I have a weird behavior of decorationType. I'm using SVG file as let gutterIconPath: string = context.asAbsolutePath("images/icon.svg");
let dt: vscode.TextEditorDecorationType = vscode.window.createTextEditorDecorationType({
gutterIconPath,
isWholeLine: true
});
vscode.window.activeTextEditor.setDecorations(
dt,
[new vscode.Range(0, 0, 0, 0)]
);
// Then suppose a user changes the color in the settings
const svgContent = '...'; // svg with a new fill attribute
fs.writeFileSync(context.asAbsolutePath(`images/icon.svg`), svgContent, 'utf8');
dt.dispose();
dt = vscode.window.createTextEditorDecorationType({
gutterIconPath,
isWholeLine: true
});
// Expect the color to change (Doesn't work...)
vscode.window.activeTextEditor.setDecorations(
dt,
[new vscode.Range(0, 0, 0, 0)]
); Any ideas on that? |
@vasilev-alex Very likely the files contents are cached by the rendering engine. You can generate a new file name every time. |
Yeah, it worked out |
thanks @alexdima, that clear and straightforward comment showed me how to solve the same problem in a different context. |
Shouldn't the docs be improved then, given that this regularly causes confusion?
Starting from setDecorations you have to click twice and then also expand the dispose method (which probably nobody does) to find that information: |
@Trass3r PR to improve docs welcome. Here is the JSDoc https://github.com/microsoft/vscode/blob/45c70c29e572de3e9ca24d993f0616fd31f05029/src/vs/vscode.d.ts#L1152 To be fair, the second sentence explains things:
|
Dispose worked for me. But if I wanted to re-set the decorator again, would I had to force the user to reload the window? That was my only solution thus far. Is there a way to re-set the decorators without reloading the entire window. |
How do I remove the decoration type defined in this example?
The text was updated successfully, but these errors were encountered: