Skip to content

Commit 8c32259

Browse files
authored
Merge pull request #7628 from dotnet/dev/jorobich/warn-misc-files
Warn in the statusbar when the active file is not part of the open workspace.
2 parents 8dd4dfc + 3562921 commit 8c32259

File tree

5 files changed

+30
-3
lines changed

5 files changed

+30
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)
55

66
# Latest
7+
* Warn when the active file is not part of the open workspace (PR: [#7628](https://github.com/dotnet/vscode-csharp/pull/7628))
8+
* Update Roslyn to 4.13.0-1.24509.4 (PR: [#7628](https://github.com/dotnet/vscode-csharp/pull/7628))
9+
* Add a WorkspaceKind property to ProjectContext. (PR: [#75384](https://github.com/dotnet/roslyn/pull/75384))
10+
* Convert more lambda rude edits to runtime rude edits (PR: [#75285](https://github.com/dotnet/roslyn/pull/75285))
11+
12+
# 2.51.x
713
* Bumped xamltools to 17.12.35403.211 (PR: [#7629](https://github.com/dotnet/vscode-csharp/pull/7629))
814
* Update Roslyn to 4.13.0-1.24503.11 (PR: [#7618](https://github.com/dotnet/vscode-csharp/pull/7618))
915
* LSP hover responses escape backticks within inline code (PR: [#75364](https://github.com/dotnet/roslyn/pull/75364))

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
}
3838
},
3939
"defaults": {
40-
"roslyn": "4.13.0-1.24503.11",
40+
"roslyn": "4.13.0-1.24509.4",
4141
"omniSharp": "1.39.11",
4242
"razor": "9.0.0-preview.24480.1",
4343
"razorOmnisharp": "7.0.0-preview.23363.1",
@@ -5597,4 +5597,4 @@
55975597
}
55985598
}
55995599
}
5600-
}
5600+
}

src/lsptoolshost/languageStatusBar.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ import { ServerState } from './serverStateChange';
1111
import { getCSharpDevKit } from '../utils/getCSharpDevKit';
1212
import { RazorLanguage } from '../razor/src/razorLanguage';
1313

14+
let currentServerState: ServerState = ServerState.Stopped;
15+
1416
export function registerLanguageStatusItems(
1517
context: vscode.ExtensionContext,
1618
languageServer: RoslynLanguageServer,
1719
languageServerEvents: RoslynLanguageServerEvents
1820
) {
21+
// Track the current server state.
22+
languageServerEvents.onServerStateChange((e) => {
23+
currentServerState = e.state;
24+
});
25+
1926
// DevKit will provide an equivalent workspace status item.
2027
if (!getCSharpDevKit()) {
2128
WorkspaceStatus.createStatusItem(context, languageServerEvents);
@@ -44,14 +51,16 @@ class WorkspaceStatus {
4451

4552
const item = vscode.languages.createLanguageStatusItem('csharp.workspaceStatus', documentSelector);
4653
item.name = vscode.l10n.t('C# Workspace Status');
54+
item.severity = vscode.LanguageStatusSeverity.Error;
55+
item.command = openSolutionCommand;
4756
context.subscriptions.push(item);
4857

4958
languageServerEvents.onServerStateChange((e) => {
5059
item.text = e.workspaceLabel;
5160
item.busy = e.state === ServerState.ProjectInitializationStarted;
5261
item.severity =
5362
e.state === ServerState.Stopped
54-
? vscode.LanguageStatusSeverity.Warning
63+
? vscode.LanguageStatusSeverity.Error
5564
: vscode.LanguageStatusSeverity.Information;
5665
item.command = e.state === ServerState.Stopped ? restartServerCommand : openSolutionCommand;
5766
});
@@ -73,6 +82,16 @@ class ProjectContextStatus {
7382

7483
projectContextService.onActiveFileContextChanged((e) => {
7584
item.text = e.context._vs_label;
85+
86+
// Show a warning when the active file is part of the Miscellaneous File workspace and
87+
// project initialization is complete.
88+
if (currentServerState === ServerState.ProjectInitializationComplete) {
89+
item.severity = e.context._vs_is_miscellaneous
90+
? vscode.LanguageStatusSeverity.Warning
91+
: vscode.LanguageStatusSeverity.Information;
92+
} else {
93+
item.severity = vscode.LanguageStatusSeverity.Information;
94+
}
7695
});
7796

7897
// Trigger a refresh, but don't block creation on the refresh completing.

src/lsptoolshost/roslynProtocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface VSProjectContext {
1717
_vs_label: string;
1818
_vs_id: string;
1919
_vs_kind: string;
20+
_vs_is_miscellaneous: boolean;
2021
}
2122

2223
export interface VSTextDocumentIdentifier extends lsp.TextDocumentIdentifier {

src/lsptoolshost/services/projectContextService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class ProjectContextService {
2626
_vs_id: '',
2727
_vs_kind: '',
2828
_vs_label: '',
29+
_vs_is_miscellaneous: false,
2930
};
3031

3132
constructor(private _languageServer: RoslynLanguageServer, _languageServerEvents: LanguageServerEvents) {

0 commit comments

Comments
 (0)