diff --git a/package-lock.json b/package-lock.json index 43ca77a..9716281 100644 --- a/package-lock.json +++ b/package-lock.json @@ -450,6 +450,11 @@ "mime-types": "^2.1.12" } }, + "fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -549,9 +554,9 @@ } }, "https-proxy-agent": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.2.tgz", - "integrity": "sha512-c8Ndjc9Bkpfx/vCJueCPy0jlP4ccCCSNDp8xwCZzPjKJUm+B+u9WX2x98Qx4n1PiMNTWo3D7KK5ifNV/yJyRzg==", + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", + "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", "dev": true, "requires": { "agent-base": "^4.3.0", diff --git a/package.json b/package.json index 6d3ba14..12630e4 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ }, "dependencies": { "vscode-languageclient": "^5.2.1", - "ws": "^6.2.1" + "ws": "^6.2.1", + "fs": "^0.0.1-security" }, "repository": { "type": "git", @@ -741,5 +742,10 @@ } } } + }, + "__metadata": { + "id": "8e21d425-1e30-4072-8436-786a9017e5c7", + "publisherDisplayName": "ccls-project", + "publisherId": "c8f976c9-da3f-47d4-a344-bc810b73caed" } } diff --git a/src/serverContext.ts b/src/serverContext.ts index dcc5ce1..a9aba32 100644 --- a/src/serverContext.ts +++ b/src/serverContext.ts @@ -1,4 +1,5 @@ import * as cp from "child_process"; +import * as fs from 'fs'; import { CancellationToken, CodeLens, @@ -304,7 +305,11 @@ export class ServerContext implements Disposable { let db_dir = config.get('misc.compilationDatabaseDirectory'); if (!db_dir || db_dir === '') db_dir = this.cwd; - const db_watcher = workspace.createFileSystemWatcher(db_dir + '/compile_commands.json', false, false, false); + const db_path = db_dir + '/compile_commands.json'; + // resolve db_path in case it is a symlink, otherwise the file system watcher + // won't catch modifications of the linked file + const db_real_path = fs.realpathSync(db_path); + const db_watcher = workspace.createFileSystemWatcher(db_real_path, false, false, false); this._dispose.push(db_watcher); db_watcher.onDidChange((e: Uri) => { this.client.sendNotification("workspace/didChangeConfiguration"); @@ -465,7 +470,7 @@ export class ServerContext implements Disposable { documentSelector: ['c', 'cpp', 'objective-c', 'objective-cpp'], // synchronize: { // configurationSection: 'ccls', - // fileEvents: workspace.createFileSystemWatcher('**/.cc') + // fileEvents: workspace.createfsWatcher('**/.cc') // }, errorHandler: new CclsErrorHandler(config), initializationFailedHandler: (e) => {