Skip to content

Commit

Permalink
Read debug options from environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
msujew committed Sep 17, 2021
1 parent 1fa4da5 commit ff575c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/generator-langium/langium-template/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export function deactivate(): Thenable<void> | undefined {
function startLanguageClient(context: vscode.ExtensionContext): LanguageClient {
const serverModule = context.asAbsolutePath(path.join('out', 'language-server', 'main'));
// The debug options for the server
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging.
// By setting `proces.env.DEBUG_BREAK` to a truthy value, the language server will wait until a debugger is attached.
const debugOptions = { execArgv: ['--nolazy', `--inspect${process.env.DEBUG_BREAK ? '-brk' : ''}=${process.env.DEBUG_SOCKET || '6009'}`] };

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
Expand Down
5 changes: 3 additions & 2 deletions packages/langium-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export function deactivate(): Thenable<void> | undefined {
function startLanguageClient(context: vscode.ExtensionContext): LanguageClient {
const serverModule = context.asAbsolutePath(path.join('out', 'language-server', 'main'));
// The debug options for the server
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging.
// By setting `proces.env.DEBUG_BREAK` to a truthy value, the language server will wait until a debugger is attached.
const debugOptions = { execArgv: ['--nolazy', `--inspect${process.env.DEBUG_BREAK ? '-brk' : ''}=${process.env.DEBUG_SOCKET || '6009'}`] };

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
Expand Down

0 comments on commit ff575c7

Please sign in to comment.