DEV Community

Adrian Matei for Codever

Posted on • Edited on • Originally published at codever.land

5

Get user input value from input box in visual studio code

Use vscode.window.showInputBox - the returned value will be undefined if the input box was canceled (e.g. pressing ESC). Otherwise the returned value will be the string typed by the user or an empty string if the user did not type anything but dismissed the input box with OK.

const searchQuery = await vscode.window.showInputBox({
  placeHolder: "Search query",
  prompt: "Search my snippets on Codever",
  value: selectedText
});
if(searchQuery === ''){
  console.log(searchQuery);
  vscode.window.showErrorMessage('A search query is mandatory to execute this action');
}

if(searchQuery !== undefined){
  const searchUrl = `https://www.codever.land/search?q=${searchQuery}&sd=my-snippets`;
  vscode.env.openExternal(Uri.parse(searchUrl));
}
Enter fullscreen mode Exit fullscreen mode

You can see it in action below:

vs-code-extension-search


The whole source for the Codever Snippets VSCode extension on Github.


Shared with ❤️ from Codever.   👉 use the copy to mine functionality to add it to your personal snippets collection.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post