bash-language-server
Advanced tools
Comparing version 4.10.0 to 4.10.1
# Bash Language Server | ||
## 4.10.1 | ||
- Handle tree-sitter-bash parse errors gracefully | ||
## 4.10.0 | ||
@@ -4,0 +8,0 @@ |
@@ -47,3 +47,10 @@ "use strict"; | ||
const fileContent = document.getText(); | ||
const tree = this.parser.parse(fileContent); | ||
let tree; | ||
try { | ||
tree = this.parser.parse(fileContent); | ||
} | ||
catch (error) { | ||
logger_1.logger.warn(`Tree sitter crashed while parsing ${uri}: ${error}`); | ||
return []; | ||
} | ||
const globalDeclarations = (0, declarations_1.getGlobalDeclarations)({ tree, uri }); | ||
@@ -50,0 +57,0 @@ const sourceCommands = sourcing.getSourceCommands({ |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "4.10.0", | ||
"version": "4.10.1", | ||
"main": "./out/server.js", | ||
@@ -9,0 +9,0 @@ "typings": "./out/server.d.ts", |
@@ -146,2 +146,20 @@ import { pathToFileURL } from 'node:url' | ||
}) | ||
it('handles tree-sitter crashes gracefully', async () => { | ||
const analyzer = await getAnalyzer({ runBackgroundAnalysis: false }) | ||
// Parse the file | ||
analyzer.analyze({ | ||
uri: FIXTURE_URI.CRASH, | ||
document: FIXTURE_DOCUMENT.CRASH, | ||
}) | ||
expect(loggerWarn).toHaveBeenCalled() | ||
expect(loggerWarn.mock.calls).toEqual([ | ||
[expect.stringContaining('Tree sitter crashed while parsing')], | ||
]) | ||
const result = analyzer.findAllSourcedUris({ uri: FIXTURE_URI.CRASH }) | ||
expect(result).toEqual(new Set([])) | ||
}) | ||
}) | ||
@@ -148,0 +166,0 @@ |
@@ -73,4 +73,10 @@ import * as fs from 'fs' | ||
const fileContent = document.getText() | ||
let tree: Parser.Tree | ||
const tree = this.parser.parse(fileContent) | ||
try { | ||
tree = this.parser.parse(fileContent) | ||
} catch (error) { | ||
logger.warn(`Tree sitter crashed while parsing ${uri}: ${error}`) | ||
return [] | ||
} | ||
@@ -77,0 +83,0 @@ const globalDeclarations = getGlobalDeclarations({ tree, uri }) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1009501
10529