microsoft/vscode

vscode.window.showInputBox does not show initial hint

rioj7 opened this issue · 4 comments

rioj7 commented
  • VSCode Version: 1.44.2
  • OS Version: Windows 8

The vscode.window.showInputBox has the option to add a validation function. This function is called on initial show of the inputBox but a possible hint is not shown.

I have an extension where the user can configure the initial value of the input box, but based on other settings this input might contain an error. I show a preview but nothing happens because of an error in the input. The user has no idea why and has to add and remove a space to see the actual error/hint.

Steps to Reproduce:

  1. Add the following command to an extension
context.subscriptions.push(vscode.commands.registerTextEditorCommand('extensionname.testTest', (editor, edit, args) => {
    function inputChanged(str) {
      return 'Something is wrong';
    }
    vscode.window.showInputBox({
      placeHolder: 'search for',
      value: "start value",
      prompt: 'What do you want to search?',
      validateInput: inputChanged
    });
  }));
  1. Modify package.json to add this command.
  2. Start/Launch the extension
  3. Call the command and you see the prompt instead of the error/hint.
  4. Add a space and you see the hint.

/duplicate

This is by design to avoid having input boxes open with an error message. When you press enter or start typing the error message is shown. /cc devanshj

Well if that's the case then we should relabel this as "*as-designed" and close it because it currently works as you described that is it shows the error message when you press enter or start typing. (I'll close the PR once this issue is closed)

Also don't forget to add "@" next time didn't get the notification for this xD, I luckily stumbled upon this via the PR. I think github should also automatically subscribe the PR author to the linked issue.

Closing as designed, thanks.