Support custom memory limit (#102)
parent
7ce298c7c8
commit
e84459db39
12
package.json
12
package.json
|
@ -54,5 +54,17 @@
|
|||
"mz": "^2.4.0",
|
||||
"semver": "^5.3.0",
|
||||
"vscode-languageclient": "^3.0.3"
|
||||
},
|
||||
"contributes": {
|
||||
"configuration": {
|
||||
"properties": {
|
||||
"php.memoryLimit": {
|
||||
"type": "string",
|
||||
"default": "-1",
|
||||
"description": "The memory limit of the php language server. [Number][K|M|G]. Use '-1' to allow unlimited use of the RAM(default).",
|
||||
"pattern": "^\\d+[KMG]?$"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,19 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
|
|||
const conf = vscode.workspace.getConfiguration('php');
|
||||
const executablePath = conf.get<string>('executablePath') || 'php';
|
||||
|
||||
const memoryLimit = conf.get<string>('memoryLimit') || '-1';
|
||||
|
||||
if (memoryLimit !== '-1' && !/^\d+[KMG]?$/.exec(memoryLimit)) {
|
||||
const selected = await vscode.window.showErrorMessage(
|
||||
'The memory limit you\'d provided is not numeric, nor "-1" nor valid php shorthand notation!',
|
||||
'Open settings'
|
||||
);
|
||||
if (selected === 'Open settings') {
|
||||
await vscode.commands.executeCommand('workbench.action.openGlobalSettings');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Check path (if PHP is available and version is ^7.0.0)
|
||||
let stdout: string;
|
||||
try {
|
||||
|
@ -52,6 +65,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
|
|||
function spawnServer(...args: string[]): ChildProcess {
|
||||
// The server is implemented in PHP
|
||||
args.unshift(context.asAbsolutePath(path.join('vendor', 'felixfbecker', 'language-server', 'bin', 'php-language-server.php')));
|
||||
args.push('--memory-limit=' + memoryLimit);
|
||||
const childProcess = spawn(executablePath, args);
|
||||
childProcess.stderr.on('data', (chunk: Buffer) => {
|
||||
console.error(chunk + '');
|
||||
|
|
Loading…
Reference in New Issue