From 0a409aff8915f2d6298bf7185e9595bff5d1bdb4 Mon Sep 17 00:00:00 2001 From: MisaJovanovic Date: Wed, 16 May 2018 20:44:13 +0200 Subject: [PATCH 1/2] Add events for changing active text editor and focusing window --- src/features/diagnosticsProvider.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/features/diagnosticsProvider.ts b/src/features/diagnosticsProvider.ts index 6ea57e51d6..136c99776b 100644 --- a/src/features/diagnosticsProvider.ts +++ b/src/features/diagnosticsProvider.ts @@ -133,7 +133,9 @@ class DiagnosticsProvider extends AbstractSupport { let d4 = vscode.workspace.onDidOpenTextDocument(event => this._onDocumentAddOrChange(event), this); let d3 = vscode.workspace.onDidChangeTextDocument(event => this._onDocumentAddOrChange(event.document), this); let d5 = vscode.workspace.onDidCloseTextDocument(this._onDocumentRemove, this); - this._disposable = new CompositeDisposable(this._diagnostics, d1, d2, d3, d4, d5); + let d6 = vscode.window.onDidChangeActiveTextEditor(event => this._onDidChangeActiveTextEditor(event), this); + let d7 = vscode.window.onDidChangeWindowState(event => this._OnDidChangeWindowState(event), this); + this._disposable = new CompositeDisposable(this._diagnostics, d1, d2, d3, d4, d5, d6, d7); // Go ahead and check for diagnostics in the currently visible editors. for (let editor of vscode.window.visibleTextEditors) { @@ -156,6 +158,19 @@ class DiagnosticsProvider extends AbstractSupport { this._disposable.dispose(); } + private _OnDidChangeWindowState(windowState: vscode.WindowState): void { + if (windowState.focused === true) { + this._onDidChangeActiveTextEditor(vscode.window.activeTextEditor); + } + } + + private _onDidChangeActiveTextEditor(textEditor: vscode.TextEditor): void { + // active text editor can be undefined. + if (textEditor != undefined && textEditor.document != null) { + this._onDocumentAddOrChange(textEditor.document); + } + } + private _onDocumentAddOrChange(document: vscode.TextDocument): void { if (document.languageId === 'csharp' && document.uri.scheme === 'file') { this._validateDocument(document); @@ -163,7 +178,7 @@ class DiagnosticsProvider extends AbstractSupport { } } - private _onDocumentRemove(document: vscode.TextDocument) { + private _onDocumentRemove(document: vscode.TextDocument): void { let key = document.uri; let didChange = false; if (this._diagnostics.get(key)) { From c908660921a1c81f94c32ae2976cb3def7b1cc2e Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Fri, 18 May 2018 15:10:39 -0700 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66f744f547..4625e46da1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ * There currently is no completion support for package references in csproj files. ([#1156](https://github.com/OmniSharp/omnisharp-vscode/issues/1156)) * As an alternative, consider installing the [MSBuild Project Tools](https://marketplace.visualstudio.com/items?itemName=tintoy.msbuild-project-tools) extension by @tintoy. + +## 1.16.0 _(Not Yet Released)_ + +#### Editor + +* Improved diagnostics by refreshing them when the active editor changes or the current window is focused. (PR: [#2317](https://github.com/OmniSharp/omnisharp-vscode/pull/2317)) _(Contributed by [@SirIntruder](https://github.com/SirIntruder)) ## 1.15.2 (May 15, 1018)