mirror of
https://github.com/Strum355/mcshader-lsp.git
synced 2025-07-23 11:15:27 +00:00
Fixed server crashing if glslangValidator wasnt found
This commit is contained in:
parent
f93c26a59d
commit
d2e58f475d
3 changed files with 46 additions and 37 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue