Skip to content

Commit 14b2528

Browse files
committed
Fix analyzer not being called when getHighlightParsingError is off
1 parent 213a517 commit 14b2528

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodejs 12.22.12

server/src/analyser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export default class Analyzer {
376376
): Parser.SyntaxNode | null {
377377
const document = this.uriToTreeSitterTrees[uri]
378378

379-
if (!document.rootNode) {
379+
if (!document?.rootNode) {
380380
// Check for lacking rootNode (due to failed parse?)
381381
return null
382382
}

server/src/server.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,20 @@ export default class BashServer {
7676
this.documents.listen(this.connection)
7777
this.documents.onDidChangeContent(async change => {
7878
const { uri } = change.document
79+
80+
// Load the tree for the modified contents into the analyzer:
81+
const analyzeDiagnostics = this.analyzer.analyze(uri, change.document)
82+
83+
// Run shellcheck diagnostics:
7984
let diagnostics: LSP.Diagnostic[] = []
8085

81-
// FIXME: re-lint on workspace folder change
8286
const folders = await connection.workspace.getWorkspaceFolders()
8387
const lintDiagnostics = await this.linter.lint(change.document, folders || [])
8488
diagnostics = diagnostics.concat(lintDiagnostics)
8589

90+
// Treesitter's diagnostics can be a bit inaccurate, so we only merge the
91+
// analyzer's diagnostics if the setting is enabled:
8692
if (config.getHighlightParsingError()) {
87-
const analyzeDiagnostics = this.analyzer.analyze(uri, change.document)
8893
diagnostics = diagnostics.concat(analyzeDiagnostics)
8994
}
9095

@@ -100,6 +105,8 @@ export default class BashServer {
100105
connection.onReferences(this.onReferences.bind(this))
101106
connection.onCompletion(this.onCompletion.bind(this))
102107
connection.onCompletionResolve(this.onCompletionResolve.bind(this))
108+
109+
// FIXME: re-lint on workspace folder change
103110
}
104111

105112
/**

0 commit comments

Comments
 (0)