jlang
jlang

Reputation: 1057

VSCode Custom Extension: Seem not to work

I'm currently trying to write an VS Code extension and it's a bit frustrating. I did everything as said here:

https://code.visualstudio.com/docs/extensions/example-hello-world

But after using yo code and entering all necessary information, I opened the respective folder VS Code hit F5 and VS Code says I should configure my launch.json (this should be done by yo code, shouldn't it?). However, when I press the debug start button, a extension-host window opens as described in that tutorial. BUT: When I try to execute the extension the command palette won't find it.

I tried several command names such as "hello world" "helloworld" or variants of the name of the extension that I gave in yo code. I also noticed the

"commands": [{ "command":"extension.sayHello", "title":"Hello World" }]

section of the package.json, but somehow I don't manage it to put it all together in order to get a simple, working vs code extension. In tutorial videos on youtube everyone can simply hit F5 after launching VS Code, what I cannot. Pretty weird somehow.

Any help is appreciated! Thanks in advance.

EDIT: Additional information.

When I activated vs code to show all exceptions (even handled) vs code stops at the following point (see default:)

at internal/process/stdio.js (core module)

// ...
case 'PIPE':
case 'TCP':
  var net = require('net');
  stream = new net.Socket({
    fd: fd,
    readable: false,
    writable: true
  });
  stream._type = 'pipe';
  break;

default:
  // VS CODE STOPS AT THE LINE FOLLOWING!
  // Probably an error on in uv_guess_handle()
  throw new Error('Implement me. Unknown stream file type!');
}
// Ignore stream errors.stream.on('error', function() {});
  } catch (error) {
stream = createDevNull();
}
//...

Hopefully it helps :(

Upvotes: 2

Views: 1963

Answers (2)

qwertzguy
qwertzguy

Reputation: 17677

I had the same issue (though didn't debug to see if it failed on the same line) and I resolved it by restarting VSCode.

Upvotes: 2

jlang
jlang

Reputation: 1057

I solved my problem by reading the tutorial with more attention. The tutorial tells you to activate the command palette by Hitting F1 not CTRL P. This solved my Problem.

I did not change anything in the code; rather it seems to be important to hit F1 instad of [CTRL] + [P] despite it actually brings up the same input. I'm still wondering why to differenciate between CTRL + P and F1 if both bring up the same control. :/

Hope it helps other beginners, too. cheers!

Upvotes: 1

Related Questions