Fixed server crashing if glslangValidator wasnt found

This commit is contained in:
Noah Santschi-Cooney 2018-06-29 19:31:56 +01:00
parent f93c26a59d
commit d2e58f475d
3 changed files with 46 additions and 37 deletions

View file

@ -24,9 +24,7 @@ connection.onInitialize((params): vsclang.InitializeResult => {
}
})
connection.onExit(() => {
})
connection.onExit(() => {})
documents.onDidOpen(onEvent)
@ -38,16 +36,23 @@ function onEvent(event: TextDocumentChangeEvent) {
preprocess(event.document, true, [event.document.uri.replace(/^file:\/\//, '')])
}
export function checkBinary(ok: () => void, fail?: () => any) {
exec(conf.glslangPath, (error) => {
if (error['code'] !== 1) {
if (fail) fail()
return
}
ok()
})
}
connection.onDidChangeConfiguration((change) => {
const temp = change.settings.mcglsl as Config
conf = new Config(temp['shaderpacksPath'], temp['glslangValidatorPath'])
exec(conf.glslangPath, (error) => {
if (error['code'] !== 1) {
connection.window.showErrorMessage(`[mc-glsl] glslangValidator not found at: ${conf.glslangPath}`)
return
}
documents.all().forEach((document) => preprocess(document, true, [document.uri.replace(/^file:\/\//, '')]))
})
checkBinary(
() => {documents.all().forEach(document => preprocess(document, true, [document.uri.replace(/^file:\/\//, '')]))},
() => {connection.window.showErrorMessage(`[mc-glsl] glslangValidator not found at: ${conf.glslangPath}`)}
)
})
connection.onCompletion((textDocumentPosition: vsclang.TextDocumentPositionParams) => completions)