Skip to content

Commit a2ed4fd

Browse files
committed
Handle case where a window is opened without an associated folder
1 parent 1be9b1e commit a2ed4fd

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "A language server for Bash",
44
"author": "Mads Hartmann",
55
"license": "MIT",
6-
"version": "1.1.0",
6+
"version": "1.1.1",
77
"publisher": "mads-hartmann",
88
"main": "out/server.js",
99
"bin": {

server/src/server.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const glob = require("glob");
2121
const fs = require("fs");
2222
import * as Path from "path";
2323

24+
const pkg = require('../package')
2425
import * as Analyser from "./analyser";
2526

2627
export function listen() {
@@ -40,22 +41,25 @@ export function listen() {
4041
documents.listen(connection);
4142

4243
connection.onInitialize((params): InitializeResult => {
44+
4345
connection.console.log(
44-
`Initialized for ${params.rootUri}, ${params.rootPath}`
46+
`Initialized server v. ${pkg.version} for ${params.rootUri}`
4547
);
4648

47-
glob("**/*.sh", { cwd: params.rootPath }, (err, paths) => {
48-
if (err != null) {
49-
connection.console.error(err);
50-
} else {
51-
paths.forEach(p => {
52-
const absolute = Path.join(params.rootPath, p);
53-
const uri = "file://" + absolute;
54-
connection.console.log("Analyzing " + uri);
55-
Analyser.analyze(uri, fs.readFileSync(absolute, "utf8"));
56-
});
57-
}
58-
});
49+
if (params.rootPath) {
50+
glob("**/*.sh", { cwd: params.rootPath }, (err, paths) => {
51+
if (err != null) {
52+
connection.console.error(err);
53+
} else {
54+
paths.forEach(p => {
55+
const absolute = Path.join(params.rootPath, p);
56+
const uri = "file://" + absolute;
57+
connection.console.log("Analyzing " + uri);
58+
Analyser.analyze(uri, fs.readFileSync(absolute, "utf8"));
59+
});
60+
}
61+
});
62+
}
5963

6064
return {
6165
capabilities: {

0 commit comments

Comments
 (0)