I just started learning about vscode extensions, and I'm wondering if there is a simple way to programmatically close the informational message window that is created via vscode.window.showInformationMessage() . If you want to reproduce, I started with the WordCount demo here and after copying / pasting the body extension.ts , as indicated in the tutorial, I made some changes to activate() , for example, like this ...
export function activate(context: ExtensionContext) { let wordCounter = new WordCounter(); let wcTimeout = null; let setWCTimeout = function() { clearWCTimeout(); wcTimeout = setTimeout(clearWCTimeout, 1000); }; let clearWCTimeout = function() { if (wcTimeout !== null) { clearTimeout(wcTimeout); wcTimeout = null;
What I tried or thought:
- calling
vscode.window.showInformationMessage() using null and an empty string - does nothing, nothing but null | a blank line results in a new informational message - disposal of the team - in fact, there was no reason to think that this would work, and the team must be re-registered before it works again.
- I tried to access the DOM just to find the Close button and click on it, but I could not find any entry point for controlling the DOM
Side note: I'm interested in best practices within this paradigm. For example, is there a popular node library that wraps js timers that I can consider? However, this is not my main concern for this post. If you want to comment on the delay mechanism ( setTimeout()/clearTimeout() ), make it constructive in terms of best practices in this environment / paradigm (outside of "this ugly", or "it's not how [you personally] do it )
source share