Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read and react to O# option changes only when devkit isnt installed #5895

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/shared/observables/createOptionStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import { Options } from '../options';
import { vscode } from '../../vscodeAdapter';
import { Observable, Observer } from 'rxjs';
import { publishBehavior } from 'rxjs/operators';
import { csharpDevkitExtensionId } from '../../utils/getCSharpDevKit';

export default function createOptionStream(vscode: vscode): Observable<Options> {
return Observable.create((observer: Observer<Options>) => {
const disposable = vscode.workspace.onDidChangeConfiguration((e) => {
//if the omnisharp or csharp configuration are affected only then read the options
if (
e.affectsConfiguration('dotnet') ||
e.affectsConfiguration('omnisharp') ||
(e.affectsConfiguration('omnisharp') && !vscode.extensions.getExtension(csharpDevkitExtensionId)) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this logic instead move to somewhere like

public static shouldOmnisharpOptionChangeTriggerReload(oldOptions: Options, newOptions: Options): boolean {

It'll probably work either way, but I'm somewhat surprised already that the Omnisharp option isn't being ignored by that.

e.affectsConfiguration('csharp')
) {
observer.next(Options.Read(vscode));
Expand Down
1 change: 1 addition & 0 deletions src/vscodeAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ export interface vscode {
workspaceFolders: readonly WorkspaceFolder[] | undefined;
};
extensions: {
getExtension(extensionId: string): Extension<any> | undefined;
all: ReadonlyArray<Extension<any>>;
};
Uri: {
Expand Down
3 changes: 3 additions & 0 deletions test/unitTests/testAssets/fakes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ export function getFakeVsCode(): vscode.vscode {
},
extensions: {
all: [],
getExtension: () => {
throw new Error('Not Implemented');
},
},
Uri: {
parse: () => {
Expand Down