mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 00:28:52 +01:00
Use ??= in more places (#163594)
This commit is contained in:
@@ -117,13 +117,9 @@ class MyCompletionItem extends vscode.CompletionItem {
|
||||
if (tsEntry.kindModifiers) {
|
||||
const kindModifiers = parseKindModifier(tsEntry.kindModifiers);
|
||||
if (kindModifiers.has(PConst.KindModifiers.optional)) {
|
||||
if (!this.insertText) {
|
||||
this.insertText = this.textLabel;
|
||||
}
|
||||
this.insertText ??= this.textLabel;
|
||||
this.filterText ??= this.textLabel;
|
||||
|
||||
if (!this.filterText) {
|
||||
this.filterText = this.textLabel;
|
||||
}
|
||||
if (typeof this.label === 'string') {
|
||||
this.label += '?';
|
||||
} else {
|
||||
|
||||
@@ -30,10 +30,7 @@ class FileReferencesCommand implements Command {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!resource) {
|
||||
resource = vscode.window.activeTextEditor?.document.uri;
|
||||
}
|
||||
|
||||
resource ??= vscode.window.activeTextEditor?.document.uri;
|
||||
if (!resource) {
|
||||
vscode.window.showErrorMessage(localize('error.noResource', "Find file references failed. No resource provided."));
|
||||
return;
|
||||
|
||||
@@ -54,14 +54,10 @@ class ConditionalRegistration {
|
||||
private update() {
|
||||
const enabled = this.conditions.every(condition => condition.value);
|
||||
if (enabled) {
|
||||
if (!this.registration) {
|
||||
this.registration = this.doRegister();
|
||||
}
|
||||
this.registration ??= this.doRegister();
|
||||
} else {
|
||||
if (this.registration) {
|
||||
this.registration.dispose();
|
||||
this.registration = undefined;
|
||||
}
|
||||
this.registration?.dispose();
|
||||
this.registration = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace TypeScriptServerPlugin {
|
||||
export class PluginManager extends Disposable {
|
||||
private readonly _pluginConfigurations = new Map<string, {}>();
|
||||
|
||||
private _plugins: Map<string, ReadonlyArray<TypeScriptServerPlugin>> | undefined;
|
||||
private _plugins?: Map<string, ReadonlyArray<TypeScriptServerPlugin>>;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -37,6 +37,7 @@ export class PluginManager extends Disposable {
|
||||
if (!this._plugins) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newPlugins = this.readPlugins();
|
||||
if (!arrays.equals(Array.from(this._plugins.values()).flat(), Array.from(newPlugins.values()).flat(), TypeScriptServerPlugin.equals)) {
|
||||
this._plugins = newPlugins;
|
||||
@@ -46,9 +47,7 @@ export class PluginManager extends Disposable {
|
||||
}
|
||||
|
||||
public get plugins(): ReadonlyArray<TypeScriptServerPlugin> {
|
||||
if (!this._plugins) {
|
||||
this._plugins = this.readPlugins();
|
||||
}
|
||||
this._plugins ??= this.readPlugins();
|
||||
return Array.from(this._plugins.values()).flat();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,9 +34,7 @@ const getRootTempDir = (() => {
|
||||
export const getInstanceTempDir = (() => {
|
||||
let dir: string | undefined;
|
||||
return () => {
|
||||
if (!dir) {
|
||||
dir = path.join(getRootTempDir(), makeRandomHexString(20));
|
||||
}
|
||||
dir ??= path.join(getRootTempDir(), makeRandomHexString(20));
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user