mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
debt - optional chaining
This commit is contained in:
parent
cfb88f21c9
commit
935b0f1c0d
|
@ -263,7 +263,7 @@ export class ContextView extends Disposable {
|
|||
const delegate = this.delegate;
|
||||
this.delegate = null;
|
||||
|
||||
if (delegate && delegate.onHide) {
|
||||
if (delegate?.onHide) {
|
||||
delegate.onHide(data);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,13 +99,13 @@ export class IconLabel extends Disposable {
|
|||
|
||||
this.labelDescriptionContainer = this._register(new FastLabelNode(dom.append(this.domNode.element, dom.$('.monaco-icon-label-description-container'))));
|
||||
|
||||
if (options && options.supportHighlights) {
|
||||
if (options?.supportHighlights) {
|
||||
this.labelNode = new HighlightedLabel(dom.append(this.labelDescriptionContainer.element, dom.$('a.label-name')), !!options.supportCodicons);
|
||||
} else {
|
||||
this.labelNode = this._register(new FastLabelNode(dom.append(this.labelDescriptionContainer.element, dom.$('a.label-name'))));
|
||||
}
|
||||
|
||||
if (options && options.supportDescriptionHighlights) {
|
||||
if (options?.supportDescriptionHighlights) {
|
||||
this.descriptionNodeFactory = () => new HighlightedLabel(dom.append(this.labelDescriptionContainer.element, dom.$('span.label-description')), !!options.supportCodicons);
|
||||
} else {
|
||||
this.descriptionNodeFactory = () => this._register(new FastLabelNode(dom.append(this.labelDescriptionContainer.element, dom.$('span.label-description'))));
|
||||
|
@ -129,10 +129,10 @@ export class IconLabel extends Disposable {
|
|||
}
|
||||
|
||||
this.domNode.className = classes.join(' ');
|
||||
this.domNode.title = options && options.title ? options.title : '';
|
||||
this.domNode.title = options?.title || '';
|
||||
|
||||
if (this.labelNode instanceof HighlightedLabel) {
|
||||
this.labelNode.set(label || '', options ? options.matches : undefined, options && options.title ? options.title : undefined, options && options.labelEscapeNewLines);
|
||||
this.labelNode.set(label || '', options?.matches, options?.title, options?.labelEscapeNewLines);
|
||||
} else {
|
||||
this.labelNode.textContent = label || '';
|
||||
}
|
||||
|
@ -144,14 +144,14 @@ export class IconLabel extends Disposable {
|
|||
|
||||
if (this.descriptionNode instanceof HighlightedLabel) {
|
||||
this.descriptionNode.set(description || '', options ? options.descriptionMatches : undefined);
|
||||
if (options && options.descriptionTitle) {
|
||||
if (options?.descriptionTitle) {
|
||||
this.descriptionNode.element.title = options.descriptionTitle;
|
||||
} else {
|
||||
this.descriptionNode.element.removeAttribute('title');
|
||||
}
|
||||
} else {
|
||||
this.descriptionNode.textContent = description || '';
|
||||
this.descriptionNode.title = options && options.descriptionTitle ? options.descriptionTitle : '';
|
||||
this.descriptionNode.title = options?.descriptionTitle || '';
|
||||
this.descriptionNode.empty = !description;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ export class InputBox extends Widget {
|
|||
|
||||
const onSelectionChange = Event.filter(domEvent(document, 'selectionchange'), () => {
|
||||
const selection = document.getSelection();
|
||||
return !!selection && selection.anchorNode === wrapper;
|
||||
return selection?.anchorNode === wrapper;
|
||||
});
|
||||
|
||||
// from DOM to ScrollableElement
|
||||
|
|
|
@ -80,20 +80,20 @@ export class KeybindingLabel {
|
|||
private renderPart(parent: HTMLElement, part: ResolvedKeybindingPart, match: PartMatches | null) {
|
||||
const modifierLabels = UILabelProvider.modifierLabels[this.os];
|
||||
if (part.ctrlKey) {
|
||||
this.renderKey(parent, modifierLabels.ctrlKey, Boolean(match && match.ctrlKey), modifierLabels.separator);
|
||||
this.renderKey(parent, modifierLabels.ctrlKey, Boolean(match?.ctrlKey), modifierLabels.separator);
|
||||
}
|
||||
if (part.shiftKey) {
|
||||
this.renderKey(parent, modifierLabels.shiftKey, Boolean(match && match.shiftKey), modifierLabels.separator);
|
||||
this.renderKey(parent, modifierLabels.shiftKey, Boolean(match?.shiftKey), modifierLabels.separator);
|
||||
}
|
||||
if (part.altKey) {
|
||||
this.renderKey(parent, modifierLabels.altKey, Boolean(match && match.altKey), modifierLabels.separator);
|
||||
this.renderKey(parent, modifierLabels.altKey, Boolean(match?.altKey), modifierLabels.separator);
|
||||
}
|
||||
if (part.metaKey) {
|
||||
this.renderKey(parent, modifierLabels.metaKey, Boolean(match && match.metaKey), modifierLabels.separator);
|
||||
this.renderKey(parent, modifierLabels.metaKey, Boolean(match?.metaKey), modifierLabels.separator);
|
||||
}
|
||||
const keyLabel = part.keyLabel;
|
||||
if (keyLabel) {
|
||||
this.renderKey(parent, keyLabel, Boolean(match && match.keyCode), '');
|
||||
this.renderKey(parent, keyLabel, Boolean(match?.keyCode), '');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ export class SelectBox extends Widget implements ISelectBoxDelegate {
|
|||
super();
|
||||
|
||||
// Default to native SelectBox for OSX unless overridden
|
||||
if (isMacintosh && !(selectBoxOptions && selectBoxOptions.useCustomDrawn)) {
|
||||
if (isMacintosh && !selectBoxOptions?.useCustomDrawn) {
|
||||
this.selectBoxDelegate = new SelectBoxNative(options, selected, styles, selectBoxOptions);
|
||||
} else {
|
||||
this.selectBoxDelegate = new SelectBoxList(options, selected, contextViewProvider, styles, selectBoxOptions);
|
||||
|
|
|
@ -129,9 +129,9 @@ export class ToolBar extends Disposable {
|
|||
}
|
||||
|
||||
private getKeybindingLabel(action: IAction): string | undefined {
|
||||
const key = this.lookupKeybindings && this.options.getKeyBinding ? this.options.getKeyBinding(action) : undefined;
|
||||
const key = this.lookupKeybindings ? this.options.getKeyBinding?.(action) : undefined;
|
||||
|
||||
return withNullAsUndefined(key && key.getLabel());
|
||||
return withNullAsUndefined(key?.getLabel());
|
||||
}
|
||||
|
||||
addPrimaryAction(primaryAction: IAction): () => void {
|
||||
|
|
|
@ -43,7 +43,7 @@ export function getPathLabel(resource: URI | string, userHomeProvider?: IUserHom
|
|||
}
|
||||
|
||||
if (hasMultipleRoots) {
|
||||
const rootName = (baseResource && baseResource.name) ? baseResource.name : basename(baseResource.uri);
|
||||
const rootName = baseResource.name ? baseResource.name : basename(baseResource.uri);
|
||||
pathLabel = pathLabel ? (rootName + ' • ' + pathLabel) : rootName; // always show root basename if there are multiple
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ export function popup(items: IContextMenuItem[], options?: IPopupOptions): void
|
|||
|
||||
ipcRenderer.removeListener(onClickChannel, onClickChannelHandler);
|
||||
|
||||
if (options && options.onHide) {
|
||||
if (options?.onHide) {
|
||||
options.onHide();
|
||||
}
|
||||
});
|
||||
|
@ -55,4 +55,4 @@ function createItem(item: IContextMenuItem, processedItems: IContextMenuItem[]):
|
|||
}
|
||||
|
||||
return serializableItem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ class WorkspaceProvider implements IWorkspaceProvider {
|
|||
) { }
|
||||
|
||||
async open(workspace: IWorkspace, options?: { reuse?: boolean, payload?: object }): Promise<void> {
|
||||
if (options && options.reuse && !options.payload && this.isSame(this.workspace, workspace)) {
|
||||
if (options?.reuse && !options.payload && this.isSame(this.workspace, workspace)) {
|
||||
return; // return early if workspace and environment is not changing and we are reusing window
|
||||
}
|
||||
|
||||
|
@ -233,12 +233,12 @@ class WorkspaceProvider implements IWorkspaceProvider {
|
|||
}
|
||||
|
||||
// Environment
|
||||
if (options && options.payload) {
|
||||
if (options?.payload) {
|
||||
targetHref += `&payload=${encodeURIComponent(JSON.stringify(options.payload))}`;
|
||||
}
|
||||
|
||||
if (targetHref) {
|
||||
if (options && options.reuse) {
|
||||
if (options?.reuse) {
|
||||
window.location.href = targetHref;
|
||||
} else {
|
||||
if (isStandalone) {
|
||||
|
@ -290,7 +290,7 @@ class WorkspaceProvider implements IWorkspaceProvider {
|
|||
|
||||
// Find payload
|
||||
let payload = Object.create(null);
|
||||
if (document && document.location && document.location.search) {
|
||||
if (document.location.search) {
|
||||
const query = document.location.search.substring(1);
|
||||
const vars = query.split('&');
|
||||
for (let p of vars) {
|
||||
|
|
|
@ -663,7 +663,7 @@ export class CodeApplication extends Disposable {
|
|||
}
|
||||
|
||||
// mac: open-file event received on startup
|
||||
if (macOpenFiles && macOpenFiles.length && !hasCliArgs && !hasFolderURIs && !hasFileURIs) {
|
||||
if (macOpenFiles.length && !hasCliArgs && !hasFolderURIs && !hasFileURIs) {
|
||||
return windowsMainService.open({
|
||||
context: OpenContext.DOCK,
|
||||
cli: args,
|
||||
|
|
|
@ -152,12 +152,12 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
|||
if (isMacintosh) {
|
||||
options.acceptFirstMouse = true; // enabled by default
|
||||
|
||||
if (windowConfig && windowConfig.clickThroughInactive === false) {
|
||||
if (windowConfig?.clickThroughInactive === false) {
|
||||
options.acceptFirstMouse = false;
|
||||
}
|
||||
}
|
||||
|
||||
const useNativeTabs = isMacintosh && windowConfig && windowConfig.nativeTabs === true;
|
||||
const useNativeTabs = isMacintosh && windowConfig?.nativeTabs === true;
|
||||
if (useNativeTabs) {
|
||||
options.tabbingIdentifier = product.nameShort; // this opts in to sierra tabs
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
|||
|
||||
// Set zoomlevel
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
const zoomLevel = windowConfig && windowConfig.zoomLevel;
|
||||
const zoomLevel = windowConfig?.zoomLevel;
|
||||
if (typeof zoomLevel === 'number') {
|
||||
windowConfiguration.zoomLevel = zoomLevel;
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
|||
|
||||
// Set Accessibility Config
|
||||
let autoDetectHighContrast = true;
|
||||
if (windowConfig && windowConfig.autoDetectHighContrast === false) {
|
||||
if (windowConfig?.autoDetectHighContrast === false) {
|
||||
autoDetectHighContrast = false;
|
||||
}
|
||||
windowConfiguration.highContrast = isWindows && autoDetectHighContrast && systemPreferences.isInvertedColorScheme();
|
||||
|
@ -825,7 +825,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
|
|||
// Multi Montior (fullscreen): try to find the previously used display
|
||||
if (state.display && state.mode === WindowMode.Fullscreen) {
|
||||
const display = displays.filter(d => d.id === state.display)[0];
|
||||
if (display && display.bounds && typeof display.bounds.x === 'number' && typeof display.bounds.y === 'number') {
|
||||
if (display && typeof display.bounds?.x === 'number' && typeof display.bounds?.y === 'number') {
|
||||
const defaults = defaultWindowState(WindowMode.Fullscreen); // make sure we have good values when the user restores the window
|
||||
defaults.x = display.bounds.x; // carefull to use displays x/y position so that the window ends up on the correct monitor
|
||||
defaults.y = display.bounds.y;
|
||||
|
|
|
@ -89,7 +89,7 @@ export class OpenerService extends Disposable implements IOpenerService {
|
|||
private async _doOpen(resource: URI, options: OpenOptions | undefined): Promise<boolean> {
|
||||
const { scheme, path, query, fragment } = resource;
|
||||
|
||||
if (equalsIgnoreCase(scheme, Schemas.mailto) || (options && options.openExternal)) {
|
||||
if (equalsIgnoreCase(scheme, Schemas.mailto) || options?.openExternal) {
|
||||
// open default mail application
|
||||
return this._doOpenExternal(resource, options);
|
||||
}
|
||||
|
@ -139,9 +139,9 @@ export class OpenerService extends Disposable implements IOpenerService {
|
|||
}
|
||||
|
||||
await this._editorService.openCodeEditor(
|
||||
{ resource, options: { selection, context: options && options.fromUserGesture ? EditorOpenContext.USER : EditorOpenContext.API } },
|
||||
{ resource, options: { selection, context: options?.fromUserGesture ? EditorOpenContext.USER : EditorOpenContext.API } },
|
||||
this._editorService.getFocusedCodeEditor(),
|
||||
options && options.openToSide
|
||||
options?.openToSide
|
||||
);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -130,7 +130,7 @@ export class BackupMainService implements IBackupMainService {
|
|||
private getHotExitConfig(): string {
|
||||
const config = this.configurationService.getValue<IFilesConfiguration>();
|
||||
|
||||
return (config && config.files && config.files.hotExit) || HotExitConfiguration.ON_EXIT;
|
||||
return config?.files?.hotExit || HotExitConfiguration.ON_EXIT;
|
||||
}
|
||||
|
||||
getEmptyWindowBackupPaths(): IEmptyWindowBackupInfo[] {
|
||||
|
|
|
@ -99,7 +99,7 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
|
|||
let ret = toDisposable(() => {
|
||||
removeFn();
|
||||
const command = this._commands.get(id);
|
||||
if (command && command.isEmpty()) {
|
||||
if (command?.isEmpty()) {
|
||||
this._commands.delete(id);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -334,7 +334,7 @@ export class ElectronMainService implements IElectronMainService {
|
|||
async reload(windowId: number | undefined, options?: { disableExtensions?: boolean }): Promise<void> {
|
||||
const window = this.windowById(windowId);
|
||||
if (window) {
|
||||
return this.lifecycleMainService.reload(window, options && options.disableExtensions ? { _: [], 'disable-extensions': true } : undefined);
|
||||
return this.lifecycleMainService.reload(window, options?.disableExtensions ? { _: [], 'disable-extensions': true } : undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ export class ElectronMainService implements IElectronMainService {
|
|||
// If the user selected to exit from an extension development host window, do not quit, but just
|
||||
// close the window unless this is the last window that is opened.
|
||||
const window = this.windowsMainService.getLastActiveWindow();
|
||||
if (window && window.isExtensionDevelopmentHost && this.windowsMainService.getWindowCount() > 1) {
|
||||
if (window?.isExtensionDevelopmentHost && this.windowsMainService.getWindowCount() > 1) {
|
||||
window.win.close();
|
||||
}
|
||||
|
||||
|
@ -369,8 +369,9 @@ export class ElectronMainService implements IElectronMainService {
|
|||
async resolveProxy(windowId: number | undefined, url: string): Promise<string | undefined> {
|
||||
return new Promise(resolve => {
|
||||
const window = this.windowById(windowId);
|
||||
if (window && window.win && window.win.webContents && window.win.webContents.session) {
|
||||
window.win.webContents.session.resolveProxy(url, proxy => resolve(proxy));
|
||||
const session = window?.win?.webContents?.session;
|
||||
if (session) {
|
||||
session.resolveProxy(url, proxy => resolve(proxy));
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
|
|
|
@ -163,15 +163,15 @@ export class FileService extends Disposable implements IFileService {
|
|||
private async doResolveFile(resource: URI, options?: IResolveFileOptions): Promise<IFileStat> {
|
||||
const provider = await this.withProvider(resource);
|
||||
|
||||
const resolveTo = options && options.resolveTo;
|
||||
const resolveSingleChildDescendants = !!(options && options.resolveSingleChildDescendants);
|
||||
const resolveMetadata = !!(options && options.resolveMetadata);
|
||||
const resolveTo = options?.resolveTo;
|
||||
const resolveSingleChildDescendants = options?.resolveSingleChildDescendants;
|
||||
const resolveMetadata = options?.resolveMetadata;
|
||||
|
||||
const stat = await provider.stat(resource);
|
||||
|
||||
let trie: TernarySearchTree<boolean> | undefined;
|
||||
|
||||
return this.toFileStat(provider, resource, stat, undefined, resolveMetadata, (stat, siblings) => {
|
||||
return this.toFileStat(provider, resource, stat, undefined, !!resolveMetadata, (stat, siblings) => {
|
||||
|
||||
// lazy trie to check for recursive resolving
|
||||
if (!trie) {
|
||||
|
@ -274,8 +274,7 @@ export class FileService extends Disposable implements IFileService {
|
|||
async createFile(resource: URI, bufferOrReadableOrStream: VSBuffer | VSBufferReadable | VSBufferReadableStream = VSBuffer.fromString(''), options?: ICreateFileOptions): Promise<IFileStatWithMetadata> {
|
||||
|
||||
// validate overwrite
|
||||
const overwrite = !!(options && options.overwrite);
|
||||
if (!overwrite && await this.exists(resource)) {
|
||||
if (!options?.overwrite && await this.exists(resource)) {
|
||||
throw new FileOperationError(localize('fileExists', "File to create already exists ({0})", this.resourceForError(resource)), FileOperationResult.FILE_MODIFIED_SINCE, options);
|
||||
}
|
||||
|
||||
|
@ -507,7 +506,7 @@ export class FileService extends Disposable implements IFileService {
|
|||
}
|
||||
|
||||
// Return early if file is too large to load
|
||||
if (options && options.limits) {
|
||||
if (options?.limits) {
|
||||
if (typeof options.limits.memory === 'number' && stat.size > options.limits.memory) {
|
||||
throw new FileOperationError(localize('fileTooLargeForHeapError', "To open a file of this size, you need to restart and allow it to use more memory"), FileOperationResult.FILE_EXCEED_MEMORY_LIMIT);
|
||||
}
|
||||
|
@ -529,7 +528,7 @@ export class FileService extends Disposable implements IFileService {
|
|||
const targetProvider = this.throwIfFileSystemIsReadonly(await this.withReadWriteProvider(target));
|
||||
|
||||
// move
|
||||
const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'move', overwrite);
|
||||
const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'move', !!overwrite);
|
||||
|
||||
// resolve and send events
|
||||
const fileStat = await this.resolve(target, { resolveMetadata: true });
|
||||
|
@ -543,7 +542,7 @@ export class FileService extends Disposable implements IFileService {
|
|||
const targetProvider = this.throwIfFileSystemIsReadonly(await this.withReadWriteProvider(target));
|
||||
|
||||
// copy
|
||||
const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'copy', overwrite);
|
||||
const mode = await this.doMoveCopy(sourceProvider, source, targetProvider, target, 'copy', !!overwrite);
|
||||
|
||||
// resolve and send events
|
||||
const fileStat = await this.resolve(target, { resolveMetadata: true });
|
||||
|
@ -552,7 +551,7 @@ export class FileService extends Disposable implements IFileService {
|
|||
return fileStat;
|
||||
}
|
||||
|
||||
private async doMoveCopy(sourceProvider: IFileSystemProviderWithFileReadWriteCapability | IFileSystemProviderWithOpenReadWriteCloseCapability, source: URI, targetProvider: IFileSystemProviderWithFileReadWriteCapability | IFileSystemProviderWithOpenReadWriteCloseCapability, target: URI, mode: 'move' | 'copy', overwrite?: boolean): Promise<'move' | 'copy'> {
|
||||
private async doMoveCopy(sourceProvider: IFileSystemProviderWithFileReadWriteCapability | IFileSystemProviderWithOpenReadWriteCloseCapability, source: URI, targetProvider: IFileSystemProviderWithFileReadWriteCapability | IFileSystemProviderWithOpenReadWriteCloseCapability, target: URI, mode: 'move' | 'copy', overwrite: boolean): Promise<'move' | 'copy'> {
|
||||
if (source.toString() === target.toString()) {
|
||||
return mode; // simulate node.js behaviour here and do a no-op if paths match
|
||||
}
|
||||
|
@ -573,7 +572,7 @@ export class FileService extends Disposable implements IFileService {
|
|||
|
||||
// same provider with fast copy: leverage copy() functionality
|
||||
if (sourceProvider === targetProvider && hasFileFolderCopyCapability(sourceProvider)) {
|
||||
await sourceProvider.copy(source, target, { overwrite: !!overwrite });
|
||||
await sourceProvider.copy(source, target, { overwrite });
|
||||
}
|
||||
|
||||
// when copying via buffer/unbuffered, we have to manually
|
||||
|
@ -595,7 +594,7 @@ export class FileService extends Disposable implements IFileService {
|
|||
|
||||
// same provider: leverage rename() functionality
|
||||
if (sourceProvider === targetProvider) {
|
||||
await sourceProvider.rename(source, target, { overwrite: !!overwrite });
|
||||
await sourceProvider.rename(source, target, { overwrite });
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
@ -744,13 +743,13 @@ export class FileService extends Disposable implements IFileService {
|
|||
const provider = this.throwIfFileSystemIsReadonly(await this.withProvider(resource));
|
||||
|
||||
// Validate trash support
|
||||
const useTrash = !!(options && options.useTrash);
|
||||
const useTrash = !!options?.useTrash;
|
||||
if (useTrash && !(provider.capabilities & FileSystemProviderCapabilities.Trash)) {
|
||||
throw new Error(localize('err.trash', "Provider does not support trash."));
|
||||
}
|
||||
|
||||
// Validate recursive
|
||||
const recursive = !!(options && options.recursive);
|
||||
const recursive = !!options?.recursive;
|
||||
if (!recursive && await this.exists(resource)) {
|
||||
const stat = await this.resolve(resource);
|
||||
if (stat.isDirectory && Array.isArray(stat.children) && stat.children.length > 0) {
|
||||
|
@ -1062,7 +1061,7 @@ export class FileService extends Disposable implements IFileService {
|
|||
private throwIfTooLarge(totalBytesRead: number, options?: IReadFileOptions): boolean {
|
||||
|
||||
// Return early if file is too large to load
|
||||
if (options && options.limits) {
|
||||
if (options?.limits) {
|
||||
if (typeof options.limits.memory === 'number' && totalBytesRead > options.limits.memory) {
|
||||
throw new FileOperationError(localize('fileTooLargeForHeapError', "To open a file of this size, you need to restart and allow it to use more memory"), FileOperationResult.FILE_EXCEED_MEMORY_LIMIT);
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ export class DiskFileSystemProvider extends Disposable implements IFileSystemPro
|
|||
try {
|
||||
|
||||
// Ensure target does not exist
|
||||
await this.validateTargetDeleted(from, to, 'move', opts && opts.overwrite);
|
||||
await this.validateTargetDeleted(from, to, 'move', opts.overwrite);
|
||||
|
||||
// Move
|
||||
await move(fromFilePath, toFilePath);
|
||||
|
@ -407,7 +407,7 @@ export class DiskFileSystemProvider extends Disposable implements IFileSystemPro
|
|||
try {
|
||||
|
||||
// Ensure target does not exist
|
||||
await this.validateTargetDeleted(from, to, 'copy', opts && opts.overwrite);
|
||||
await this.validateTargetDeleted(from, to, 'copy', opts.overwrite);
|
||||
|
||||
// Copy
|
||||
await copy(fromFilePath, toFilePath);
|
||||
|
|
|
@ -128,7 +128,7 @@ export class LaunchMainService implements ILaunchMainService {
|
|||
// Otherwise check for settings
|
||||
else {
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
const openWithoutArgumentsInNewWindowConfig = (windowConfig && windowConfig.openWithoutArgumentsInNewWindow) || 'default' /* default */;
|
||||
const openWithoutArgumentsInNewWindowConfig = windowConfig?.openWithoutArgumentsInNewWindow || 'default' /* default */;
|
||||
switch (openWithoutArgumentsInNewWindowConfig) {
|
||||
case 'on':
|
||||
openNewWindow = true;
|
||||
|
|
|
@ -504,11 +504,11 @@ export class LifecycleMainService extends Disposable implements ILifecycleMainSe
|
|||
this.logService.trace('Lifecycle#relaunch()');
|
||||
|
||||
const args = process.argv.slice(1);
|
||||
if (options && options.addArgs) {
|
||||
if (options?.addArgs) {
|
||||
args.push(...options.addArgs);
|
||||
}
|
||||
|
||||
if (options && options.removeArgs) {
|
||||
if (options?.removeArgs) {
|
||||
for (const a of options.removeArgs) {
|
||||
const idx = args.indexOf(a);
|
||||
if (idx >= 0) {
|
||||
|
|
|
@ -367,9 +367,9 @@ export class Menubar {
|
|||
label: nls.localize('miQuit', "Quit {0}", product.nameLong), click: () => {
|
||||
const lastActiveWindow = this.windowsMainService.getLastActiveWindow();
|
||||
if (
|
||||
this.windowsMainService.getWindowCount() === 0 || // allow to quit when no more windows are open
|
||||
!!BrowserWindow.getFocusedWindow() || // allow to quit when window has focus (fix for https://github.com/Microsoft/vscode/issues/39191)
|
||||
(lastActiveWindow && lastActiveWindow.isMinimized()) // allow to quit when window has no focus but is minimized (https://github.com/Microsoft/vscode/issues/63000)
|
||||
this.windowsMainService.getWindowCount() === 0 || // allow to quit when no more windows are open
|
||||
!!BrowserWindow.getFocusedWindow() || // allow to quit when window has focus (fix for https://github.com/Microsoft/vscode/issues/39191)
|
||||
lastActiveWindow?.isMinimized() // allow to quit when window has no focus but is minimized (https://github.com/Microsoft/vscode/issues/63000)
|
||||
) {
|
||||
this.electronMainService.quit(undefined);
|
||||
}
|
||||
|
@ -717,7 +717,7 @@ export class Menubar {
|
|||
let activeBrowserWindow = BrowserWindow.getFocusedWindow();
|
||||
if (!activeBrowserWindow) {
|
||||
const lastActiveWindow = this.windowsMainService.getLastActiveWindow();
|
||||
if (lastActiveWindow && lastActiveWindow.isMinimized()) {
|
||||
if (lastActiveWindow?.isMinimized()) {
|
||||
activeBrowserWindow = lastActiveWindow.win;
|
||||
}
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ export class Menubar {
|
|||
const binding = typeof commandId === 'string' ? this.keybindings[commandId] : undefined;
|
||||
|
||||
// Apply binding if there is one
|
||||
if (binding && binding.label) {
|
||||
if (binding?.label) {
|
||||
|
||||
// if the binding is native, we can just apply it
|
||||
if (binding.isNative !== false) {
|
||||
|
|
|
@ -374,12 +374,12 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
|
||||
openEmptyWindow(context: OpenContext, options?: IOpenEmptyWindowOptions): ICodeWindow[] {
|
||||
let cli = this.environmentService.args;
|
||||
const remote = options && options.remoteAuthority;
|
||||
const remote = options?.remoteAuthority;
|
||||
if (cli && (cli.remote !== remote)) {
|
||||
cli = { ...cli, remote };
|
||||
}
|
||||
|
||||
const forceReuseWindow = options && options.forceReuseWindow;
|
||||
const forceReuseWindow = options?.forceReuseWindow;
|
||||
const forceNewWindow = !forceReuseWindow;
|
||||
|
||||
return this.open({ context, cli, forceEmpty: true, forceNewWindow, forceReuseWindow });
|
||||
|
@ -568,7 +568,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
windows,
|
||||
newWindow: openFilesInNewWindow,
|
||||
context: openConfig.context,
|
||||
fileUri: fileToCheck && fileToCheck.fileUri,
|
||||
fileUri: fileToCheck?.fileUri,
|
||||
localWorkspaceResolver: workspace => workspace.configPath.scheme === Schemas.file ? this.workspacesMainService.resolveLocalWorkspaceSync(workspace.configPath) : null
|
||||
});
|
||||
|
||||
|
@ -621,7 +621,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
const windowsOnWorkspace = arrays.coalesce(allWorkspacesToOpen.map(workspaceToOpen => findWindowOnWorkspace(WindowsMainService.WINDOWS, workspaceToOpen.workspace)));
|
||||
if (windowsOnWorkspace.length > 0) {
|
||||
const windowOnWorkspace = windowsOnWorkspace[0];
|
||||
const fileInputsForWindow = (fileInputs && fileInputs.remoteAuthority === windowOnWorkspace.remoteAuthority) ? fileInputs : undefined;
|
||||
const fileInputsForWindow = (fileInputs?.remoteAuthority === windowOnWorkspace.remoteAuthority) ? fileInputs : undefined;
|
||||
|
||||
// Do open files
|
||||
usedWindows.push(this.doOpenFilesInExistingWindow(openConfig, windowOnWorkspace, fileInputsForWindow));
|
||||
|
@ -641,7 +641,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
}
|
||||
|
||||
const remoteAuthority = workspaceToOpen.remoteAuthority;
|
||||
const fileInputsForWindow = (fileInputs && fileInputs.remoteAuthority === remoteAuthority) ? fileInputs : undefined;
|
||||
const fileInputsForWindow = (fileInputs?.remoteAuthority === remoteAuthority) ? fileInputs : undefined;
|
||||
|
||||
// Do open folder
|
||||
usedWindows.push(this.doOpenFolderOrWorkspace(openConfig, workspaceToOpen, openFolderInNewWindow, fileInputsForWindow));
|
||||
|
@ -663,7 +663,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
const windowsOnFolderPath = arrays.coalesce(allFoldersToOpen.map(folderToOpen => findWindowOnWorkspace(WindowsMainService.WINDOWS, folderToOpen.folderUri)));
|
||||
if (windowsOnFolderPath.length > 0) {
|
||||
const windowOnFolderPath = windowsOnFolderPath[0];
|
||||
const fileInputsForWindow = fileInputs && fileInputs.remoteAuthority === windowOnFolderPath.remoteAuthority ? fileInputs : undefined;
|
||||
const fileInputsForWindow = fileInputs?.remoteAuthority === windowOnFolderPath.remoteAuthority ? fileInputs : undefined;
|
||||
|
||||
// Do open files
|
||||
usedWindows.push(this.doOpenFilesInExistingWindow(openConfig, windowOnFolderPath, fileInputsForWindow));
|
||||
|
@ -684,7 +684,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
}
|
||||
|
||||
const remoteAuthority = folderToOpen.remoteAuthority;
|
||||
const fileInputsForWindow = (fileInputs && fileInputs.remoteAuthority === remoteAuthority) ? fileInputs : undefined;
|
||||
const fileInputsForWindow = (fileInputs?.remoteAuthority === remoteAuthority) ? fileInputs : undefined;
|
||||
|
||||
// Do open folder
|
||||
usedWindows.push(this.doOpenFolderOrWorkspace(openConfig, folderToOpen, openFolderInNewWindow, fileInputsForWindow));
|
||||
|
@ -703,7 +703,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
if (allEmptyToRestore.length > 0) {
|
||||
allEmptyToRestore.forEach(emptyWindowBackupInfo => {
|
||||
const remoteAuthority = emptyWindowBackupInfo.remoteAuthority;
|
||||
const fileInputsForWindow = (fileInputs && fileInputs.remoteAuthority === remoteAuthority) ? fileInputs : undefined;
|
||||
const fileInputsForWindow = (fileInputs?.remoteAuthority === remoteAuthority) ? fileInputs : undefined;
|
||||
|
||||
usedWindows.push(this.openInBrowserWindow({
|
||||
userEnv: openConfig.userEnv,
|
||||
|
@ -966,12 +966,12 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
for (const openedWindow of openedWindows) {
|
||||
if (openedWindow.workspace) { // Workspaces
|
||||
const pathToOpen = this.parseUri({ workspaceUri: openedWindow.workspace.configPath }, { remoteAuthority: openedWindow.remoteAuthority });
|
||||
if (pathToOpen && pathToOpen.workspace) {
|
||||
if (pathToOpen?.workspace) {
|
||||
windowsToOpen.push(pathToOpen);
|
||||
}
|
||||
} else if (openedWindow.folderUri) { // Folders
|
||||
const pathToOpen = this.parseUri({ folderUri: openedWindow.folderUri }, { remoteAuthority: openedWindow.remoteAuthority });
|
||||
if (pathToOpen && pathToOpen.folderUri) {
|
||||
if (pathToOpen?.folderUri) {
|
||||
windowsToOpen.push(pathToOpen);
|
||||
}
|
||||
} else if (restoreWindows !== 'folders' && openedWindow.backupPath && !openedWindow.remoteAuthority) { // Local windows that were empty. Empty windows with backups will always be restored in open()
|
||||
|
@ -996,7 +996,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
restoreWindows = 'all'; // always reopen all windows when an update was applied
|
||||
} else {
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
restoreWindows = ((windowConfig && windowConfig.restoreWindows) || 'one');
|
||||
restoreWindows = windowConfig?.restoreWindows || 'one';
|
||||
|
||||
if (['all', 'folders', 'one', 'none'].indexOf(restoreWindows) === -1) {
|
||||
restoreWindows = 'one';
|
||||
|
@ -1173,7 +1173,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
this.workspacesHistoryMainService.removeFromRecentlyOpened([fileUri]); // since file does not seem to exist anymore, remove from recent
|
||||
|
||||
// assume this is a file that does not yet exist
|
||||
if (options && options.ignoreFileNotFound) {
|
||||
if (options?.ignoreFileNotFound) {
|
||||
return {
|
||||
fileUri,
|
||||
remoteAuthority,
|
||||
|
@ -1189,8 +1189,8 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
|
||||
// let the user settings override how folders are open in a new window or same window unless we are forced
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
const openFolderInNewWindowConfig = (windowConfig && windowConfig.openFoldersInNewWindow) || 'default' /* default */;
|
||||
const openFilesInNewWindowConfig = (windowConfig && windowConfig.openFilesInNewWindow) || 'off' /* default */;
|
||||
const openFolderInNewWindowConfig = windowConfig?.openFoldersInNewWindow || 'default' /* default */;
|
||||
const openFilesInNewWindowConfig = windowConfig?.openFilesInNewWindow || 'off' /* default */;
|
||||
|
||||
let openFolderInNewWindow = (openConfig.preferNewWindow || openConfig.forceNewWindow) && !openConfig.forceReuseWindow;
|
||||
if (!openConfig.forceNewWindow && !openConfig.forceReuseWindow && (openFolderInNewWindowConfig === 'on' || openFolderInNewWindowConfig === 'off')) {
|
||||
|
@ -1378,12 +1378,12 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
// Window state is not from a previous session: only allow fullscreen if we inherit it or user wants fullscreen
|
||||
let allowFullscreen: boolean;
|
||||
if (state.hasDefaultState) {
|
||||
allowFullscreen = (windowConfig && windowConfig.newWindowDimensions && ['fullscreen', 'inherit'].indexOf(windowConfig.newWindowDimensions) >= 0);
|
||||
allowFullscreen = (windowConfig?.newWindowDimensions && ['fullscreen', 'inherit'].indexOf(windowConfig.newWindowDimensions) >= 0);
|
||||
}
|
||||
|
||||
// Window state is from a previous session: only allow fullscreen when we got updated or user wants to restore
|
||||
else {
|
||||
allowFullscreen = this.lifecycleMainService.wasRestarted || (windowConfig && windowConfig.restoreFullscreen);
|
||||
allowFullscreen = this.lifecycleMainService.wasRestarted || windowConfig?.restoreFullscreen;
|
||||
|
||||
if (allowFullscreen && isMacintosh && WindowsMainService.WINDOWS.some(win => win.isFullScreen)) {
|
||||
// macOS: Electron does not allow to restore multiple windows in
|
||||
|
@ -1566,7 +1566,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
|
|||
// Check for newWindowDimensions setting and adjust accordingly
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
let ensureNoOverlap = true;
|
||||
if (windowConfig && windowConfig.newWindowDimensions) {
|
||||
if (windowConfig?.newWindowDimensions) {
|
||||
if (windowConfig.newWindowDimensions === 'maximized') {
|
||||
state.mode = WindowMode.Maximized;
|
||||
ensureNoOverlap = false;
|
||||
|
|
|
@ -111,7 +111,7 @@ export function findWindowOnExtensionDevelopmentPath<W extends IWindowContext>(w
|
|||
for (const window of windows) {
|
||||
// match on extension development path. The path can be one or more paths or uri strings, using paths.isEqual is not 100% correct but good enough
|
||||
const currPaths = window.extensionDevelopmentPath;
|
||||
if (currPaths && currPaths.some(p => matches(p))) {
|
||||
if (currPaths?.some(p => matches(p))) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,7 +247,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain
|
|||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (error && error.code !== 'ENOENT') {
|
||||
if (error.code !== 'ENOENT') {
|
||||
this.logService.warn(`Unable to read folders in ${this.untitledWorkspacesHome} (${error}).`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ export class WorkspacesService implements AddFirstParameterToFunctions<IWorkspac
|
|||
|
||||
async getRecentlyOpened(windowId: number): Promise<IRecentlyOpened> {
|
||||
const window = this.windowsMainService.getWindowById(windowId);
|
||||
if (window && window.config) {
|
||||
if (window?.config) {
|
||||
return this.workspacesHistoryMainService.getRecentlyOpened(window.config.workspace, window.config.folderUri, window.config.filesToOpenOrCreate);
|
||||
}
|
||||
|
||||
|
|
|
@ -557,7 +557,7 @@ function listFocusFirst(accessor: ServicesAccessor, options?: { fromFocused: boo
|
|||
else if (focused) {
|
||||
const tree = focused;
|
||||
|
||||
tree.focusFirst({ origin: 'keyboard' }, options && options.fromFocused ? tree.getFocus() : undefined);
|
||||
tree.focusFirst({ origin: 'keyboard' }, options?.fromFocused ? tree.getFocus() : undefined);
|
||||
tree.reveal(tree.getFocus());
|
||||
}
|
||||
}
|
||||
|
@ -609,7 +609,7 @@ function listFocusLast(accessor: ServicesAccessor, options?: { fromFocused: bool
|
|||
else if (focused) {
|
||||
const tree = focused;
|
||||
|
||||
tree.focusLast({ origin: 'keyboard' }, options && options.fromFocused ? tree.getFocus() : undefined);
|
||||
tree.focusLast({ origin: 'keyboard' }, options?.fromFocused ? tree.getFocus() : undefined);
|
||||
tree.reveal(tree.getFocus());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ abstract class BaseOpenRecentAction extends Action {
|
|||
});
|
||||
|
||||
if (pick) {
|
||||
return this.hostService.openWindow([pick.openable], { forceNewWindow: keyMods && keyMods.ctrlCmd });
|
||||
return this.hostService.openWindow([pick.openable], { forceNewWindow: keyMods?.ctrlCmd });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
|||
|
||||
// macOS Native Tabs
|
||||
const windowConfig = this.configurationService.getValue<IWindowsConfiguration>();
|
||||
HasMacNativeTabsContext.bindTo(this.contextKeyService).set(windowConfig && windowConfig.window && windowConfig.window.nativeTabs);
|
||||
HasMacNativeTabsContext.bindTo(this.contextKeyService).set(windowConfig?.window?.nativeTabs);
|
||||
|
||||
// Development
|
||||
IsDevelopmentContext.bindTo(this.contextKeyService).set(!this.environmentService.isBuilt || this.environmentService.isExtensionDevelopment);
|
||||
|
@ -197,7 +197,7 @@ export class WorkbenchContextKeysHandler extends Disposable {
|
|||
const activeControl = this.editorService.activeControl;
|
||||
const visibleEditors = this.editorService.visibleControls;
|
||||
|
||||
this.textCompareEditorActiveContext.set(!!activeControl && activeControl.getId() === TEXT_DIFF_EDITOR_ID);
|
||||
this.textCompareEditorActiveContext.set(activeControl?.getId() === TEXT_DIFF_EDITOR_ID);
|
||||
this.textCompareEditorVisibleContext.set(visibleEditors.some(control => control.getId() === TEXT_DIFF_EDITOR_ID));
|
||||
|
||||
if (visibleEditors.length > 0) {
|
||||
|
|
|
@ -113,7 +113,7 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): Array<ID
|
|||
if (e.dataTransfer && e.dataTransfer.files) {
|
||||
for (let i = 0; i < e.dataTransfer.files.length; i++) {
|
||||
const file = e.dataTransfer.files[i];
|
||||
if (file && file.path /* Electron only */ && !resources.some(r => r.resource.fsPath === file.path) /* prevent duplicates */) {
|
||||
if (file?.path /* Electron only */ && !resources.some(r => r.resource.fsPath === file.path) /* prevent duplicates */) {
|
||||
try {
|
||||
resources.push({ resource: URI.file(file.path), isExternal: true });
|
||||
} catch (error) {
|
||||
|
@ -360,7 +360,7 @@ export function fillResourceDataTransfers(accessor: ServicesAccessor, resources:
|
|||
for (const textEditorWidget of textEditorWidgets) {
|
||||
if (isCodeEditor(textEditorWidget)) {
|
||||
const model = textEditorWidget.getModel();
|
||||
if (model && model.uri && model.uri.toString() === file.resource.toString()) {
|
||||
if (model?.uri?.toString() === file.resource.toString()) {
|
||||
viewState = textEditorWidget.saveViewState();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -457,7 +457,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
|||
|
||||
// Files to diff is exclusive
|
||||
return pathsToEditors(configuration.filesToDiff, fileService).then(filesToDiff => {
|
||||
if (filesToDiff && filesToDiff.length === 2) {
|
||||
if (filesToDiff?.length === 2) {
|
||||
return [{
|
||||
leftResource: filesToDiff[0].resource,
|
||||
rightResource: filesToDiff[1].resource,
|
||||
|
|
|
@ -107,7 +107,7 @@ export abstract class TogglePanelAction extends Action {
|
|||
private isPanelActive(): boolean {
|
||||
const activePanel = this.panelService.getActivePanel();
|
||||
|
||||
return !!activePanel && activePanel.getId() === this.panelId;
|
||||
return activePanel?.getId() === this.panelId;
|
||||
}
|
||||
|
||||
private isPanelFocused(): boolean {
|
||||
|
|
|
@ -60,7 +60,7 @@ export class ViewletActivityAction extends ActivityAction {
|
|||
const activeViewlet = this.viewletService.getActiveViewlet();
|
||||
|
||||
// Hide sidebar if selected viewlet already visible
|
||||
if (sideBarVisible && activeViewlet && activeViewlet.getId() === this.activity.id) {
|
||||
if (sideBarVisible && activeViewlet?.getId() === this.activity.id) {
|
||||
this.logAction('hide');
|
||||
this.layoutService.setSideBarHidden(true);
|
||||
return true;
|
||||
|
@ -95,7 +95,7 @@ export class ToggleViewletAction extends Action {
|
|||
const activeViewlet = this.viewletService.getActiveViewlet();
|
||||
|
||||
// Hide sidebar if selected viewlet already visible
|
||||
if (sideBarVisible && activeViewlet && activeViewlet.getId() === this._viewlet.id) {
|
||||
if (sideBarVisible && activeViewlet?.getId() === this._viewlet.id) {
|
||||
this.layoutService.setSideBarHidden(true);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
|
@ -185,9 +185,9 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
|||
const viewletDescriptor = this.viewletService.getViewlet(viewlet.getId());
|
||||
if (viewletDescriptor) {
|
||||
const viewContainer = this.getViewContainer(viewletDescriptor.id);
|
||||
if (viewContainer && viewContainer.hideIfEmpty) {
|
||||
if (viewContainer?.hideIfEmpty) {
|
||||
const viewDescriptors = this.viewsService.getViewDescriptors(viewContainer);
|
||||
if (viewDescriptors && viewDescriptors.activeViewDescriptors.length === 0) {
|
||||
if (viewDescriptors?.activeViewDescriptors.length === 0) {
|
||||
this.hideComposite(viewletDescriptor.id); // Update the composite bar by hiding
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
|||
} else {
|
||||
const cachedComposite = this.cachedViewlets.filter(c => c.id === compositeId)[0];
|
||||
compositeActions = {
|
||||
activityAction: this.instantiationService.createInstance(PlaceHolderViewletActivityAction, compositeId, cachedComposite && cachedComposite.name ? cachedComposite.name : compositeId, cachedComposite && cachedComposite.iconUrl ? URI.revive(cachedComposite.iconUrl) : undefined),
|
||||
activityAction: this.instantiationService.createInstance(PlaceHolderViewletActivityAction, compositeId, cachedComposite?.name || compositeId, cachedComposite?.iconUrl ? URI.revive(cachedComposite.iconUrl) : undefined),
|
||||
pinnedAction: new PlaceHolderToggleCompositePinnedAction(compositeId, this.compositeBar)
|
||||
};
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
|||
for (const viewlet of viewlets) {
|
||||
const cachedViewlet = this.cachedViewlets.filter(({ id }) => id === viewlet.id)[0];
|
||||
const activeViewlet = this.viewletService.getActiveViewlet();
|
||||
const isActive = activeViewlet && activeViewlet.getId() === viewlet.id;
|
||||
const isActive = activeViewlet?.getId() === viewlet.id;
|
||||
|
||||
if (isActive || !this.shouldBeHidden(viewlet.id, cachedViewlet)) {
|
||||
this.compositeBar.addComposite(viewlet);
|
||||
|
@ -358,7 +358,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
|||
for (const viewlet of viewlets) {
|
||||
this.enableCompositeActions(viewlet);
|
||||
const viewContainer = this.getViewContainer(viewlet.id);
|
||||
if (viewContainer && viewContainer.hideIfEmpty) {
|
||||
if (viewContainer?.hideIfEmpty) {
|
||||
const viewDescriptors = this.viewsService.getViewDescriptors(viewContainer);
|
||||
if (viewDescriptors) {
|
||||
this.onDidChangeActiveViews(viewlet, viewDescriptors);
|
||||
|
@ -392,7 +392,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
|
|||
return false;
|
||||
}
|
||||
|
||||
return cachedViewlet && cachedViewlet.views && cachedViewlet.views.length
|
||||
return cachedViewlet?.views && cachedViewlet.views.length
|
||||
? cachedViewlet.views.every(({ when }) => !!when && !this.contextKeyService.contextMatchesRules(ContextKeyExpr.deserialize(when)))
|
||||
: viewletId === TEST_VIEW_CONTAINER_ID /* Hide Test viewlet for the first time or it had no views registered before */;
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
|
|||
|
||||
isPinned(compositeId: string): boolean {
|
||||
const item = this.model.findItem(compositeId);
|
||||
return item && item.pinned;
|
||||
return item?.pinned;
|
||||
}
|
||||
|
||||
move(compositeId: string, toCompositeId: string): void {
|
||||
|
@ -275,7 +275,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
|
|||
|
||||
getAction(compositeId: string): ActivityAction {
|
||||
const item = this.model.findItem(compositeId);
|
||||
return item && item.activityAction;
|
||||
return item?.activityAction;
|
||||
}
|
||||
|
||||
private computeSizes(items: ICompositeBarModelItem[]): void {
|
||||
|
@ -402,7 +402,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
|
|||
() => this.model.activeItem ? this.model.activeItem.id : undefined,
|
||||
(compositeId: string) => {
|
||||
const item = this.model.findItem(compositeId);
|
||||
return item && item.activity[0] && item.activity[0].badge;
|
||||
return item?.activity?.[0].badge;
|
||||
},
|
||||
this.options.getOnCompositeClickAction,
|
||||
this.options.colors
|
||||
|
|
|
@ -293,7 +293,7 @@ export class ActivityActionViewItem extends BaseActionViewItem {
|
|||
|
||||
// Title
|
||||
let title: string;
|
||||
if (badge && badge.getDescription()) {
|
||||
if (badge?.getDescription()) {
|
||||
if (this.activity.name) {
|
||||
title = nls.localize('badgeTitle', "{0} - {1}", this.activity.name, badge.getDescription());
|
||||
} else {
|
||||
|
|
|
@ -32,7 +32,7 @@ import { attachProgressBarStyler } from 'vs/platform/theme/common/styler';
|
|||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { Dimension, append, $, addClass, hide, show, addClasses } from 'vs/base/browser/dom';
|
||||
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
|
||||
import { assertIsDefined } from 'vs/base/common/types';
|
||||
import { assertIsDefined, withNullAsUndefined } from 'vs/base/common/types';
|
||||
|
||||
export interface ICompositeTitleLabel {
|
||||
|
||||
|
@ -311,7 +311,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
|||
|
||||
const keybinding = this.keybindingService.lookupKeybinding(compositeId);
|
||||
|
||||
this.titleLabel.updateTitle(compositeId, compositeTitle, (keybinding && keybinding.getLabel()) || undefined);
|
||||
this.titleLabel.updateTitle(compositeId, compositeTitle, withNullAsUndefined(keybinding?.getLabel()));
|
||||
|
||||
const toolBar = assertIsDefined(this.toolBar);
|
||||
toolBar.setAriaLabel(nls.localize('ariaCompositeToolbarLabel', "{0} actions", compositeTitle));
|
||||
|
|
|
@ -752,7 +752,7 @@ export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsCon
|
|||
const selection: Array<IEditorIdentifier | IEditorGroup> = list.getSelectedElements().filter(onlyEditorGroupAndEditor);
|
||||
|
||||
// Only respect selection if it contains focused element
|
||||
if (selection && selection.some(s => {
|
||||
if (selection?.some(s => {
|
||||
if (isEditorGroup(s)) {
|
||||
return s.id === focus.groupId;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ export class EditorControl extends Disposable {
|
|||
|
||||
// If the input did not change, return early and only apply the options
|
||||
// unless the options instruct us to force open it even if it is the same
|
||||
const forceReload = options && options.forceReload;
|
||||
const forceReload = options?.forceReload;
|
||||
const inputMatches = control.input && control.input.matches(editor);
|
||||
if (inputMatches && !forceReload) {
|
||||
|
||||
|
|
|
@ -288,7 +288,7 @@ class DropOverlay extends Themable {
|
|||
}
|
||||
|
||||
private isCopyOperation(e: DragEvent, draggedEditor?: IEditorIdentifier): boolean {
|
||||
if (draggedEditor && draggedEditor.editor instanceof EditorInput && !draggedEditor.editor.supportsSplitEditor()) {
|
||||
if (draggedEditor?.editor instanceof EditorInput && !draggedEditor.editor.supportsSplitEditor()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -826,7 +826,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
// Determine options
|
||||
const openEditorOptions: IEditorOpenOptions = {
|
||||
index: options ? options.index : undefined,
|
||||
pinned: !this.accessor.partOptions.enablePreview || editor.isDirty() || (options && options.pinned) || (options && typeof options.index === 'number'),
|
||||
pinned: !this.accessor.partOptions.enablePreview || editor.isDirty() || options?.pinned || typeof options?.index === 'number',
|
||||
active: this._group.count === 0 || !options || !options.inactive
|
||||
};
|
||||
|
||||
|
@ -840,13 +840,13 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
let activateGroup = false;
|
||||
let restoreGroup = false;
|
||||
|
||||
if (options && options.activation === EditorActivation.ACTIVATE) {
|
||||
if (options?.activation === EditorActivation.ACTIVATE) {
|
||||
// Respect option to force activate an editor group.
|
||||
activateGroup = true;
|
||||
} else if (options && options.activation === EditorActivation.RESTORE) {
|
||||
} else if (options?.activation === EditorActivation.RESTORE) {
|
||||
// Respect option to force restore an editor group.
|
||||
restoreGroup = true;
|
||||
} else if (options && options.activation === EditorActivation.PRESERVE) {
|
||||
} else if (options?.activation === EditorActivation.PRESERVE) {
|
||||
// Respect option to preserve active editor group.
|
||||
activateGroup = false;
|
||||
restoreGroup = false;
|
||||
|
@ -931,7 +931,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
}
|
||||
|
||||
// If the context is USER, we try to show a modal dialog instead of a background notification
|
||||
if (options && options.context === EditorOpenContext.USER) {
|
||||
if (options?.context === EditorOpenContext.USER) {
|
||||
const buttons: string[] = [];
|
||||
if (Array.isArray(errorActions) && errorActions.length > 0) {
|
||||
errorActions.forEach(action => buttons.push(action.label));
|
||||
|
@ -1114,7 +1114,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
}
|
||||
|
||||
// Do close
|
||||
this.doCloseEditor(editor, options && options.preserveFocus ? false : undefined);
|
||||
this.doCloseEditor(editor, options?.preserveFocus ? false : undefined);
|
||||
}
|
||||
|
||||
private doCloseEditor(editor: EditorInput, focusNext = (this.accessor.activeGroup === this), fromError?: boolean): void {
|
||||
|
@ -1363,7 +1363,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
|
|||
|
||||
// Close active editor last if contained in editors list to close
|
||||
if (closeActiveEditor) {
|
||||
this.doCloseActiveEditor(options && options.preserveFocus ? false : undefined);
|
||||
this.doCloseActiveEditor(options?.preserveFocus ? false : undefined);
|
||||
}
|
||||
|
||||
// Forward to title control
|
||||
|
|
|
@ -494,7 +494,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
|
|||
|
||||
const group = this.doAddGroup(locationView, direction);
|
||||
|
||||
if (options && options.activate) {
|
||||
if (options?.activate) {
|
||||
this.doSetGroupActive(group);
|
||||
}
|
||||
|
||||
|
@ -748,7 +748,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
|
|||
const inactive = !sourceView.isActive(editor) || this._activeGroup !== sourceView;
|
||||
const copyOptions: ICopyEditorOptions = { index, inactive, preserveFocus: inactive };
|
||||
|
||||
if (options && options.mode === MergeGroupMode.COPY_EDITORS) {
|
||||
if (options?.mode === MergeGroupMode.COPY_EDITORS) {
|
||||
sourceView.copyEditor(editor, targetView, copyOptions);
|
||||
} else {
|
||||
sourceView.moveEditor(editor, targetView, copyOptions);
|
||||
|
@ -870,7 +870,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
|
|||
|
||||
private doCreateGridControlWithPreviousState(): boolean {
|
||||
const uiState: IEditorPartUIState = this.workspaceMemento[EditorPart.EDITOR_PART_UI_STATE_STORAGE_KEY];
|
||||
if (uiState && uiState.serializedGrid) {
|
||||
if (uiState?.serializedGrid) {
|
||||
try {
|
||||
|
||||
// MRU
|
||||
|
|
|
@ -375,7 +375,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
|
|||
picks.unshift({ type: 'separator', label: nls.localize('indentView', "change view") });
|
||||
|
||||
const action = await this.quickInputService.pick(picks, { placeHolder: nls.localize('pickAction', "Select Action"), matchOnDetail: true });
|
||||
return action && action.run();
|
||||
return action?.run();
|
||||
}
|
||||
|
||||
private updateTabFocusModeElement(visible: boolean): void {
|
||||
|
@ -783,7 +783,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
|
|||
// We only support text based editors that have a model associated
|
||||
// This ensures we do not show the encoding picker while an editor
|
||||
// is still loading.
|
||||
if (editor && editorWidget && editorWidget.hasModel()) {
|
||||
if (editor && editorWidget?.hasModel()) {
|
||||
const encodingSupport: IEncodingSupport | null = editor.input ? toEditorWithEncodingSupport(editor.input) : null;
|
||||
if (encodingSupport) {
|
||||
const rawEncoding = encodingSupport.getEncoding();
|
||||
|
@ -884,7 +884,7 @@ export class ChangeModeAction extends Action {
|
|||
const resource = this.editorService.activeEditor ? toResource(this.editorService.activeEditor, { supportSideBySide: SideBySideEditor.MASTER }) : null;
|
||||
|
||||
let hasLanguageSupport = !!resource;
|
||||
if (resource && resource.scheme === Schemas.untitled && !this.untitledEditorService.hasAssociatedFilePath(resource)) {
|
||||
if (resource?.scheme === Schemas.untitled && !this.untitledEditorService.hasAssociatedFilePath(resource)) {
|
||||
hasLanguageSupport = false; // no configuration for untitled resources (e.g. "Untitled-1")
|
||||
}
|
||||
|
||||
|
@ -1043,11 +1043,11 @@ export class ChangeModeAction extends Action {
|
|||
let fakeResource: URI | undefined;
|
||||
|
||||
const extensions = this.modeService.getExtensions(lang);
|
||||
if (extensions && extensions.length) {
|
||||
if (extensions?.length) {
|
||||
fakeResource = URI.file(extensions[0]);
|
||||
} else {
|
||||
const filenames = this.modeService.getFilenames(lang);
|
||||
if (filenames && filenames.length) {
|
||||
if (filenames?.length) {
|
||||
fakeResource = URI.file(filenames[0]);
|
||||
}
|
||||
}
|
||||
|
@ -1091,12 +1091,12 @@ export class ChangeEOLAction extends Action {
|
|||
{ label: nlsEOLCRLF, eol: EndOfLineSequence.CRLF },
|
||||
];
|
||||
|
||||
const selectedIndex = (textModel && textModel.getEOL() === '\n') ? 0 : 1;
|
||||
const selectedIndex = (textModel?.getEOL() === '\n') ? 0 : 1;
|
||||
|
||||
const eol = await this.quickInputService.pick(EOLOptions, { placeHolder: nls.localize('pickEndOfLine', "Select End of Line Sequence"), activeItem: EOLOptions[selectedIndex] });
|
||||
if (eol) {
|
||||
const activeCodeEditor = getCodeEditor(this.editorService.activeTextEditorWidget);
|
||||
if (activeCodeEditor && activeCodeEditor.hasModel() && isWritableCodeEditor(activeCodeEditor)) {
|
||||
if (activeCodeEditor?.hasModel() && isWritableCodeEditor(activeCodeEditor)) {
|
||||
textModel = activeCodeEditor.getModel();
|
||||
textModel.pushEOL(eol.eol);
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ export class AbstractTextResourceEditor extends BaseTextEditor {
|
|||
const isReadonly = !(this.input instanceof UntitledEditorInput);
|
||||
|
||||
let ariaLabel: string;
|
||||
const inputName = input && input.getName();
|
||||
const inputName = input?.getName();
|
||||
if (isReadonly) {
|
||||
ariaLabel = inputName ? nls.localize('readonlyEditorWithInputAriaLabel', "{0}. Readonly text editor.", inputName) : nls.localize('readonlyEditorAriaLabel', "Readonly text editor.");
|
||||
} else {
|
||||
|
|
|
@ -228,7 +228,7 @@ export abstract class TitleControl extends Themable {
|
|||
const activeControl = this.group.activeControl;
|
||||
if (activeControl instanceof BaseEditor) {
|
||||
const codeEditor = getCodeEditor(activeControl.getControl());
|
||||
const scopedContextKeyService = codeEditor && codeEditor.invokeWithinContext(accessor => accessor.get(IContextKeyService)) || this.contextKeyService;
|
||||
const scopedContextKeyService = codeEditor?.invokeWithinContext(accessor => accessor.get(IContextKeyService)) || this.contextKeyService;
|
||||
const titleBarMenu = this.menuService.createMenu(MenuId.EditorTitle, scopedContextKeyService);
|
||||
this.editorToolBarMenuDisposables.add(titleBarMenu);
|
||||
this.editorToolBarMenuDisposables.add(titleBarMenu.onDidChange(() => {
|
||||
|
|
|
@ -306,7 +306,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
|
|||
}
|
||||
}
|
||||
|
||||
if (key && key.get()) {
|
||||
if (key?.get()) {
|
||||
return; // already active context
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
|
|||
const registry = Registry.as<IQuickOpenRegistry>(Extensions.Quickopen);
|
||||
const handlerDescriptor = registry.getQuickOpenHandler(value);
|
||||
const defaultHandlerDescriptor = registry.getDefaultQuickOpenHandler();
|
||||
const instantProgress = handlerDescriptor && handlerDescriptor.instantProgress;
|
||||
const instantProgress = handlerDescriptor?.instantProgress;
|
||||
const contextKey = handlerDescriptor ? handlerDescriptor.contextKey : defaultHandlerDescriptor.contextKey;
|
||||
|
||||
// Reset Progress
|
||||
|
@ -451,7 +451,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
|
|||
// If we have matching entries from history we want to show them directly and not wait for the other results to come in
|
||||
// This also applies when we used to have entries from a previous run and now there are no more history results matching
|
||||
const previousInput = quickOpenWidget.getInput();
|
||||
const wasShowingHistory = previousInput && previousInput.entries && previousInput.entries.some(e => e instanceof EditorHistoryEntry || e instanceof EditorHistoryEntryGroup);
|
||||
const wasShowingHistory = previousInput?.entries?.some(e => e instanceof EditorHistoryEntry || e instanceof EditorHistoryEntryGroup);
|
||||
if (wasShowingHistory || matchingHistoryEntries.length > 0) {
|
||||
(async () => {
|
||||
if (resolvedHandler.hasShortResponseTime()) {
|
||||
|
@ -476,7 +476,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
|
|||
}
|
||||
|
||||
// merge history and default handler results
|
||||
const handlerResults = (result && result.entries) || [];
|
||||
const handlerResults = result?.entries || [];
|
||||
this.mergeResults(quickOpenWidget, quickOpenModel, handlerResults, types.withNullAsUndefined(resolvedHandler.getGroupLabel()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ export class TitlebarPart extends Part implements ITitleService {
|
|||
// Compute active editor folder
|
||||
const editorResource = editor ? toResource(editor) : undefined;
|
||||
let editorFolderResource = editorResource ? resources.dirname(editorResource) : undefined;
|
||||
if (editorFolderResource && editorFolderResource.path === '.') {
|
||||
if (editorFolderResource?.path === '.') {
|
||||
editorFolderResource = undefined;
|
||||
}
|
||||
|
||||
|
@ -311,7 +311,7 @@ export class TitlebarPart extends Part implements ITitleService {
|
|||
const rootPath = root ? this.labelService.getUriLabel(root) : '';
|
||||
const folderName = folder ? folder.name : '';
|
||||
const folderPath = folder ? this.labelService.getUriLabel(folder.uri) : '';
|
||||
const dirty = editor && editor.isDirty() ? TitlebarPart.TITLE_DIRTY : '';
|
||||
const dirty = editor?.isDirty() ? TitlebarPart.TITLE_DIRTY : '';
|
||||
const appName = this.environmentService.appNameLong;
|
||||
const remoteName = this.environmentService.configuration.remoteAuthority;
|
||||
const separator = TitlebarPart.TITLE_SEPARATOR;
|
||||
|
|
|
@ -46,10 +46,10 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
|
|||
weight: weight,
|
||||
when: (descriptor.keybindingContext || when ? ContextKeyExpr.and(descriptor.keybindingContext, when) : null),
|
||||
primary: keybindings ? keybindings.primary : 0,
|
||||
secondary: keybindings && keybindings.secondary,
|
||||
win: keybindings && keybindings.win,
|
||||
mac: keybindings && keybindings.mac,
|
||||
linux: keybindings && keybindings.linux
|
||||
secondary: keybindings?.secondary,
|
||||
win: keybindings?.win,
|
||||
mac: keybindings?.mac,
|
||||
linux: keybindings?.linux
|
||||
});
|
||||
|
||||
// menu item
|
||||
|
@ -112,7 +112,7 @@ Registry.add(Extensions.WorkbenchActions, new class implements IWorkbenchActionR
|
|||
|
||||
// otherwise run and dispose
|
||||
try {
|
||||
const from = args && args.from || 'keybinding';
|
||||
const from = args?.from || 'keybinding';
|
||||
await actionInstance.run(undefined, { from });
|
||||
} finally {
|
||||
actionInstance.dispose();
|
||||
|
|
|
@ -1063,7 +1063,7 @@ export function toResource(editor: IEditorInput | undefined, options?: IResource
|
|||
return undefined;
|
||||
}
|
||||
|
||||
if (options && options.supportSideBySide && editor instanceof SideBySideEditorInput) {
|
||||
if (options?.supportSideBySide && editor instanceof SideBySideEditorInput) {
|
||||
editor = options.supportSideBySide === SideBySideEditor.MASTER ? editor.master : editor.details;
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ export class EditorGroup extends Disposable {
|
|||
|
||||
for (const editor of this.editors) {
|
||||
const editorResource = toResource(editor, { supportSideBySide: SideBySideEditor.MASTER });
|
||||
if (editorResource && editorResource.toString() === resource.toString()) {
|
||||
if (editorResource?.toString() === resource.toString()) {
|
||||
return editor;
|
||||
}
|
||||
}
|
||||
|
@ -176,8 +176,8 @@ export class EditorGroup extends Disposable {
|
|||
openEditor(editor: EditorInput, options?: IEditorOpenOptions): void {
|
||||
const index = this.indexOf(editor);
|
||||
|
||||
const makePinned = options && options.pinned;
|
||||
const makeActive = (options && options.active) || !this.activeEditor || (!makePinned && this.matches(this.preview, this.activeEditor));
|
||||
const makePinned = options?.pinned;
|
||||
const makeActive = options?.active || !this.activeEditor || (!makePinned && this.matches(this.preview, this.activeEditor));
|
||||
|
||||
// New editor
|
||||
if (index === -1) {
|
||||
|
|
|
@ -45,7 +45,7 @@ export class TextDiffEditorModel extends DiffEditorModel {
|
|||
}
|
||||
|
||||
private updateTextDiffEditorModel(): void {
|
||||
if (this.originalModel && this.originalModel.isResolved() && this.modifiedModel && this.modifiedModel.isResolved()) {
|
||||
if (this.originalModel?.isResolved() && this.modifiedModel?.isResolved()) {
|
||||
|
||||
// Create new
|
||||
if (!this._textDiffEditorModel) {
|
||||
|
|
|
@ -190,7 +190,7 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
|
|||
|
||||
// mark the untitled editor as non-dirty once its content becomes empty and we do
|
||||
// not have an associated path set. we never want dirty indicator in that case.
|
||||
if (!this._hasAssociatedFilePath && this.textEditorModel && this.textEditorModel.getLineCount() === 1 && this.textEditorModel.getLineContent(1) === '') {
|
||||
if (!this._hasAssociatedFilePath && this.textEditorModel.getLineCount() === 1 && this.textEditorModel.getLineContent(1) === '') {
|
||||
this.setDirty(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ export function isStatusbarInDebugMode(debugService: IDebugService): boolean {
|
|||
}
|
||||
|
||||
const session = debugService.getViewModel().focusedSession;
|
||||
const isRunningWithoutDebug = session && session.configuration && session.configuration.noDebug;
|
||||
const isRunningWithoutDebug = session?.configuration?.noDebug;
|
||||
if (isRunningWithoutDebug) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
|
|||
}
|
||||
|
||||
private onConfigurationUpdated(configuration: IWorkbenchEditorConfiguration): void {
|
||||
if (configuration.workbench && configuration.workbench.editor && typeof configuration.workbench.editor.closeOnFileDelete === 'boolean') {
|
||||
if (typeof configuration.workbench?.editor?.closeOnFileDelete === 'boolean') {
|
||||
this.closeOnFileDelete = configuration.workbench.editor.closeOnFileDelete;
|
||||
} else {
|
||||
this.closeOnFileDelete = false; // default
|
||||
|
@ -265,7 +265,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
|
|||
const editors = this.editorService.visibleControls;
|
||||
|
||||
for (const editor of editors) {
|
||||
if (editor && editor.input && editor.group === group) {
|
||||
if (editor?.input && editor.group === group) {
|
||||
const editorResource = editor.input.getResource();
|
||||
if (editorResource && resource.toString() === editorResource.toString()) {
|
||||
const control = editor.getControl();
|
||||
|
@ -320,7 +320,7 @@ export class FileEditorTracker extends Disposable implements IWorkbenchContribut
|
|||
let isBinaryEditor = false;
|
||||
if (editor instanceof SideBySideEditor) {
|
||||
const masterEditor = editor.getMasterEditor();
|
||||
isBinaryEditor = !!masterEditor && masterEditor.getId() === BINARY_FILE_EDITOR_ID;
|
||||
isBinaryEditor = masterEditor?.getId() === BINARY_FILE_EDITOR_ID;
|
||||
} else {
|
||||
isBinaryEditor = editor.getId() === BINARY_FILE_EDITOR_ID;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ export class TextFileEditor extends BaseTextEditor {
|
|||
|
||||
private onFilesChanged(e: FileChangesEvent): void {
|
||||
const deleted = e.getDeleted();
|
||||
if (deleted && deleted.length) {
|
||||
if (deleted?.length) {
|
||||
this.clearTextEditorViewState(deleted.map(d => d.resource));
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ export class TextFileEditor extends BaseTextEditor {
|
|||
|
||||
protected getAriaLabel(): string {
|
||||
const input = this.input;
|
||||
const inputName = input && input.getName();
|
||||
const inputName = input?.getName();
|
||||
|
||||
let ariaLabel: string;
|
||||
if (inputName) {
|
||||
|
|
|
@ -241,7 +241,7 @@ export class ExplorerViewlet extends ViewContainerViewlet {
|
|||
|
||||
focus(): void {
|
||||
const explorerView = this.getView(ExplorerView.ID);
|
||||
if (explorerView && explorerView.isExpanded()) {
|
||||
if (explorerView?.isExpanded()) {
|
||||
explorerView.focus();
|
||||
} else {
|
||||
super.focus();
|
||||
|
|
|
@ -762,7 +762,7 @@ export function validateFileName(item: ExplorerItem, name: string): string | nul
|
|||
|
||||
if (name !== item.name) {
|
||||
// Do not allow to overwrite existing file
|
||||
const child = parent && parent.getChild(name);
|
||||
const child = parent?.getChild(name);
|
||||
if (child && child !== item) {
|
||||
return nls.localize('fileNameExistsError', "A file or folder **{0}** already exists at this location. Please choose a different name.", name);
|
||||
}
|
||||
|
@ -778,7 +778,7 @@ export function validateFileName(item: ExplorerItem, name: string): string | nul
|
|||
}
|
||||
|
||||
function trimLongName(name: string): string {
|
||||
if (name && name.length > 255) {
|
||||
if (name?.length > 255) {
|
||||
return `${name.substr(0, 255)}...`;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ async function doSave(
|
|||
|
||||
// Pin the active editor if we are saving it
|
||||
const activeControl = editorService.activeControl;
|
||||
const activeEditorResource = activeControl && activeControl.input && activeControl.input.getResource();
|
||||
const activeEditorResource = activeControl?.input?.getResource();
|
||||
if (activeControl && activeEditorResource && isEqual(activeEditorResource, resource)) {
|
||||
activeControl.group.pinEditor(activeControl.input);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ async function saveAll(saveAllArguments: any, editorService: IEditorService, unt
|
|||
groupIdToUntitledResourceInput.forEach((inputs, groupId) => {
|
||||
inputs.forEach(i => {
|
||||
const targetResult = result.results.filter(r => r.success && isEqual(r.source, i.resource)).pop();
|
||||
if (targetResult && targetResult.target) {
|
||||
if (targetResult?.target) {
|
||||
i.resource = targetResult.target;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ export function getResourceForCommand(resource: URI | object | undefined, listSe
|
|||
}
|
||||
|
||||
let list = listService.lastFocusedList;
|
||||
if (list && list.getHTMLElement() === document.activeElement) {
|
||||
if (list?.getHTMLElement() === document.activeElement) {
|
||||
let focus: unknown;
|
||||
if (list instanceof List) {
|
||||
const focused = list.getFocusedElements();
|
||||
|
@ -46,7 +46,7 @@ export function getResourceForCommand(resource: URI | object | undefined, listSe
|
|||
|
||||
export function getMultiSelectedResources(resource: URI | object | undefined, listService: IListService, editorService: IEditorService): Array<URI> {
|
||||
const list = listService.lastFocusedList;
|
||||
if (list && list.getHTMLElement() === document.activeElement) {
|
||||
if (list?.getHTMLElement() === document.activeElement) {
|
||||
// Explorer
|
||||
if (list instanceof WorkbenchAsyncDataTree) {
|
||||
const selection = list.getSelection().map((fs: ExplorerItem) => fs.resource);
|
||||
|
|
|
@ -83,7 +83,7 @@ export class SaveErrorHandler extends Disposable implements ISaveErrorHandler, I
|
|||
const activeInput = this.editorService.activeEditor;
|
||||
if (activeInput instanceof DiffEditorInput && activeInput.originalInput instanceof ResourceEditorInput && activeInput.modifiedInput instanceof FileEditorInput) {
|
||||
const resource = activeInput.originalInput.getResource();
|
||||
if (resource && resource.scheme === CONFLICT_RESOLUTION_SCHEME) {
|
||||
if (resource?.scheme === CONFLICT_RESOLUTION_SCHEME) {
|
||||
isActiveEditorSaveConflictResolution = true;
|
||||
activeConflictResolutionResource = activeInput.modifiedInput.getResource();
|
||||
}
|
||||
|
|
|
@ -357,7 +357,7 @@ export class ExplorerView extends ViewletPanel {
|
|||
// React on events
|
||||
|
||||
private onConfigurationUpdated(configuration: IFilesConfiguration, event?: IConfigurationChangeEvent): void {
|
||||
this.autoReveal = configuration && configuration.explorer && configuration.explorer.autoReveal;
|
||||
this.autoReveal = configuration?.explorer?.autoReveal;
|
||||
|
||||
// Push down config updates to components of viewer
|
||||
let needsRefresh = false;
|
||||
|
|
|
@ -303,7 +303,7 @@ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
|
|||
let needsRefresh = false;
|
||||
this.contextService.getWorkspace().folders.forEach(folder => {
|
||||
const configuration = this.configurationService.getValue<IFilesConfiguration>({ resource: folder.uri });
|
||||
const excludesConfig: glob.IExpression = (configuration && configuration.files && configuration.files.exclude) || Object.create(null);
|
||||
const excludesConfig: glob.IExpression = configuration?.files?.exclude || Object.create(null);
|
||||
|
||||
if (!needsRefresh) {
|
||||
const cached = this.hiddenExpressionPerRoot.get(folder.uri.toString());
|
||||
|
|
|
@ -66,7 +66,7 @@ export class DirtyFilesTracker extends Disposable implements IWorkbenchContribut
|
|||
|
||||
// Only dirty models that are not PENDING_SAVE
|
||||
const model = this.textFileService.models.get(e.resource);
|
||||
const shouldOpen = model && model.isDirty() && !model.hasState(ModelState.PENDING_SAVE);
|
||||
const shouldOpen = model?.isDirty() && !model.hasState(ModelState.PENDING_SAVE);
|
||||
|
||||
// Only if not open already
|
||||
return shouldOpen && !this.editorService.isOpen({ resource: e.resource });
|
||||
|
|
|
@ -211,11 +211,11 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
|
|||
private decorateLabel(label: string): string {
|
||||
const model = this.textFileService.models.get(this.resource);
|
||||
|
||||
if (model && model.hasState(ModelState.ORPHAN)) {
|
||||
if (model?.hasState(ModelState.ORPHAN)) {
|
||||
return localize('orphanedFile', "{0} (deleted)", label);
|
||||
}
|
||||
|
||||
if (model && model.isReadonly()) {
|
||||
if (model?.isReadonly()) {
|
||||
return localize('readonlyFile', "{0} (read-only)", label);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ function getFileEventsExcludes(configurationService: IConfigurationService, root
|
|||
const scope = root ? { resource: root } : undefined;
|
||||
const configuration = scope ? configurationService.getValue<IFilesConfiguration>(scope) : configurationService.getValue<IFilesConfiguration>();
|
||||
|
||||
return (configuration && configuration.files && configuration.files.exclude) || Object.create(null);
|
||||
return configuration?.files?.exclude || Object.create(null);
|
||||
}
|
||||
|
||||
export class ExplorerService implements IExplorerService {
|
||||
|
@ -377,7 +377,7 @@ export class ExplorerService implements IExplorerService {
|
|||
}
|
||||
|
||||
private onConfigurationUpdated(configuration: IFilesConfiguration, event?: IConfigurationChangeEvent): void {
|
||||
const configSortOrder = configuration && configuration.explorer && configuration.explorer.sortOrder || 'default';
|
||||
const configSortOrder = configuration?.explorer?.sortOrder || 'default';
|
||||
if (this._sortOrder !== configSortOrder) {
|
||||
const shouldRefresh = this._sortOrder !== undefined;
|
||||
this._sortOrder = configSortOrder;
|
||||
|
|
|
@ -107,7 +107,7 @@ export class WorkspaceWatcher extends Disposable {
|
|||
// Compute the watcher exclude rules from configuration
|
||||
const excludes: string[] = [];
|
||||
const config = this.configurationService.getValue<IFilesConfiguration>({ resource });
|
||||
if (config.files && config.files.watcherExclude) {
|
||||
if (config.files?.watcherExclude) {
|
||||
for (const key in config.files.watcherExclude) {
|
||||
if (config.files.watcherExclude[key] === true) {
|
||||
excludes.push(key);
|
||||
|
|
|
@ -35,26 +35,11 @@ import { timeout } from 'vs/base/common/async';
|
|||
|
||||
export const ALL_COMMANDS_PREFIX = '>';
|
||||
|
||||
let lastCommandPaletteInput: string;
|
||||
let commandHistory: LRUCache<string, number>;
|
||||
let commandCounter = 1;
|
||||
|
||||
interface ISerializedCommandHistory {
|
||||
usesLRU?: boolean;
|
||||
entries: { key: string; value: number }[];
|
||||
}
|
||||
|
||||
function resolveCommandHistory(configurationService: IConfigurationService): number {
|
||||
const config = <IWorkbenchQuickOpenConfiguration>configurationService.getValue();
|
||||
|
||||
let commandHistory = config.workbench && config.workbench.commandPalette && config.workbench.commandPalette.history;
|
||||
if (typeof commandHistory !== 'number') {
|
||||
commandHistory = CommandsHistory.DEFAULT_COMMANDS_HISTORY_LENGTH;
|
||||
}
|
||||
|
||||
return commandHistory;
|
||||
}
|
||||
|
||||
class CommandsHistory extends Disposable {
|
||||
|
||||
static readonly DEFAULT_COMMANDS_HISTORY_LENGTH = 50;
|
||||
|
@ -62,7 +47,10 @@ class CommandsHistory extends Disposable {
|
|||
private static readonly PREF_KEY_CACHE = 'commandPalette.mru.cache';
|
||||
private static readonly PREF_KEY_COUNTER = 'commandPalette.mru.counter';
|
||||
|
||||
private commandHistoryLength = 0;
|
||||
private static cache: LRUCache<string, number> | undefined;
|
||||
private static counter = 1;
|
||||
|
||||
private configuredCommandsHistoryLength = 0;
|
||||
|
||||
constructor(
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
|
@ -81,10 +69,10 @@ class CommandsHistory extends Disposable {
|
|||
}
|
||||
|
||||
private updateConfiguration(): void {
|
||||
this.commandHistoryLength = resolveCommandHistory(this.configurationService);
|
||||
this.configuredCommandsHistoryLength = CommandsHistory.getConfiguredCommandHistoryLength(this.configurationService);
|
||||
|
||||
if (commandHistory && commandHistory.limit !== this.commandHistoryLength) {
|
||||
commandHistory.limit = this.commandHistoryLength;
|
||||
if (CommandsHistory.cache && CommandsHistory.cache.limit !== this.configuredCommandsHistoryLength) {
|
||||
CommandsHistory.cache.limit = this.configuredCommandsHistoryLength;
|
||||
|
||||
CommandsHistory.saveState(this.storageService);
|
||||
}
|
||||
|
@ -101,7 +89,7 @@ class CommandsHistory extends Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
commandHistory = new LRUCache<string, number>(this.commandHistoryLength, 1);
|
||||
const cache = CommandsHistory.cache = new LRUCache<string, number>(this.configuredCommandsHistoryLength, 1);
|
||||
if (serializedCache) {
|
||||
let entries: { key: string; value: number }[];
|
||||
if (serializedCache.usesLRU) {
|
||||
|
@ -109,31 +97,60 @@ class CommandsHistory extends Disposable {
|
|||
} else {
|
||||
entries = serializedCache.entries.sort((a, b) => a.value - b.value);
|
||||
}
|
||||
entries.forEach(entry => commandHistory.set(entry.key, entry.value));
|
||||
entries.forEach(entry => cache.set(entry.key, entry.value));
|
||||
}
|
||||
|
||||
commandCounter = this.storageService.getNumber(CommandsHistory.PREF_KEY_COUNTER, StorageScope.GLOBAL, commandCounter);
|
||||
CommandsHistory.counter = this.storageService.getNumber(CommandsHistory.PREF_KEY_COUNTER, StorageScope.GLOBAL, CommandsHistory.counter);
|
||||
}
|
||||
|
||||
push(commandId: string): void {
|
||||
commandHistory.set(commandId, commandCounter++); // set counter to command
|
||||
if (!CommandsHistory.cache) {
|
||||
return;
|
||||
}
|
||||
|
||||
CommandsHistory.cache.set(commandId, CommandsHistory.counter++); // set counter to command
|
||||
|
||||
CommandsHistory.saveState(this.storageService);
|
||||
}
|
||||
|
||||
peek(commandId: string): number | undefined {
|
||||
return commandHistory.peek(commandId);
|
||||
return CommandsHistory.cache?.peek(commandId);
|
||||
}
|
||||
|
||||
static saveState(storageService: IStorageService): void {
|
||||
if (!CommandsHistory.cache) {
|
||||
return;
|
||||
}
|
||||
|
||||
const serializedCache: ISerializedCommandHistory = { usesLRU: true, entries: [] };
|
||||
commandHistory.forEach((value, key) => serializedCache.entries.push({ key, value }));
|
||||
CommandsHistory.cache.forEach((value, key) => serializedCache.entries.push({ key, value }));
|
||||
|
||||
storageService.store(CommandsHistory.PREF_KEY_CACHE, JSON.stringify(serializedCache), StorageScope.GLOBAL);
|
||||
storageService.store(CommandsHistory.PREF_KEY_COUNTER, commandCounter, StorageScope.GLOBAL);
|
||||
storageService.store(CommandsHistory.PREF_KEY_COUNTER, CommandsHistory.counter, StorageScope.GLOBAL);
|
||||
}
|
||||
|
||||
static getConfiguredCommandHistoryLength(configurationService: IConfigurationService): number {
|
||||
const config = <IWorkbenchQuickOpenConfiguration>configurationService.getValue();
|
||||
|
||||
const configuredCommandHistoryLength = config.workbench?.commandPalette?.history;
|
||||
if (typeof configuredCommandHistoryLength === 'number') {
|
||||
return configuredCommandHistoryLength;
|
||||
}
|
||||
|
||||
return CommandsHistory.DEFAULT_COMMANDS_HISTORY_LENGTH;
|
||||
}
|
||||
|
||||
static clearHistory(configurationService: IConfigurationService, storageService: IStorageService): void {
|
||||
const commandHistoryLength = CommandsHistory.getConfiguredCommandHistoryLength(configurationService);
|
||||
CommandsHistory.cache = new LRUCache<string, number>(commandHistoryLength);
|
||||
CommandsHistory.counter = 1;
|
||||
|
||||
CommandsHistory.saveState(storageService);
|
||||
}
|
||||
}
|
||||
|
||||
let lastCommandPaletteInput: string | undefined = undefined;
|
||||
|
||||
export class ShowAllCommandsAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.showCommands';
|
||||
|
@ -150,7 +167,7 @@ export class ShowAllCommandsAction extends Action {
|
|||
|
||||
run(): Promise<void> {
|
||||
const config = <IWorkbenchQuickOpenConfiguration>this.configurationService.getValue();
|
||||
const restoreInput = config.workbench && config.workbench.commandPalette && config.workbench.commandPalette.preserveInput === true;
|
||||
const restoreInput = config.workbench?.commandPalette?.preserveInput === true;
|
||||
|
||||
// Show with last command palette input if any and configured
|
||||
let value = ALL_COMMANDS_PREFIX;
|
||||
|
@ -179,12 +196,9 @@ export class ClearCommandHistoryAction extends Action {
|
|||
}
|
||||
|
||||
run(): Promise<void> {
|
||||
const commandHistoryLength = resolveCommandHistory(this.configurationService);
|
||||
const commandHistoryLength = CommandsHistory.getConfiguredCommandHistoryLength(this.configurationService);
|
||||
if (commandHistoryLength > 0) {
|
||||
commandHistory = new LRUCache<string, number>(commandHistoryLength);
|
||||
commandCounter = 1;
|
||||
|
||||
CommandsHistory.saveState(this.storageService);
|
||||
CommandsHistory.clearHistory(this.configurationService, this.storageService);
|
||||
}
|
||||
|
||||
return Promise.resolve(undefined);
|
||||
|
@ -408,7 +422,7 @@ export class CommandsHandler extends QuickOpenHandler implements IDisposable {
|
|||
}
|
||||
|
||||
private updateConfiguration(): void {
|
||||
this.commandHistoryEnabled = resolveCommandHistory(this.configurationService) > 0;
|
||||
this.commandHistoryEnabled = CommandsHistory.getConfiguredCommandHistoryLength(this.configurationService) > 0;
|
||||
}
|
||||
|
||||
async getResults(searchValue: string, token: CancellationToken): Promise<QuickOpenModel> {
|
||||
|
|
|
@ -196,7 +196,7 @@ export class ViewPickerHandler extends QuickOpenHandler {
|
|||
|
||||
private hasToShowViewlet(viewlet: ViewletDescriptor): boolean {
|
||||
const viewContainer = Registry.as<IViewContainersRegistry>(ViewExtensions.ViewContainersRegistry).get(viewlet.id);
|
||||
if (viewContainer && viewContainer.hideIfEmpty) {
|
||||
if (viewContainer?.hideIfEmpty) {
|
||||
const viewsCollection = this.viewsService.getViewDescriptors(viewContainer);
|
||||
return !!viewsCollection && viewsCollection.activeViewDescriptors.length > 0;
|
||||
}
|
||||
|
|
|
@ -57,13 +57,13 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
|
|||
let changed = false;
|
||||
|
||||
// Tree horizontal scrolling support
|
||||
if (config.workbench && config.workbench.list && typeof config.workbench.list.horizontalScrolling === 'boolean' && config.workbench.list.horizontalScrolling !== this.treeHorizontalScrolling) {
|
||||
if (typeof config.workbench?.list?.horizontalScrolling === 'boolean' && config.workbench.list.horizontalScrolling !== this.treeHorizontalScrolling) {
|
||||
this.treeHorizontalScrolling = config.workbench.list.horizontalScrolling;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Debug console word wrap
|
||||
if (config.debug && typeof config.debug.console.wordWrap === 'boolean' && config.debug.console.wordWrap !== this.debugConsoleWordWrap) {
|
||||
if (typeof config.debug?.console.wordWrap === 'boolean' && config.debug.console.wordWrap !== this.debugConsoleWordWrap) {
|
||||
this.debugConsoleWordWrap = config.debug.console.wordWrap;
|
||||
changed = true;
|
||||
}
|
||||
|
@ -71,44 +71,44 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
|
|||
if (isNative) {
|
||||
|
||||
// Titlebar style
|
||||
if (config.window && config.window.titleBarStyle !== this.titleBarStyle && (config.window.titleBarStyle === 'native' || config.window.titleBarStyle === 'custom')) {
|
||||
if (typeof config.window?.titleBarStyle === 'string' && config.window?.titleBarStyle !== this.titleBarStyle && (config.window.titleBarStyle === 'native' || config.window.titleBarStyle === 'custom')) {
|
||||
this.titleBarStyle = config.window.titleBarStyle;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// macOS: Native tabs
|
||||
if (isMacintosh && config.window && typeof config.window.nativeTabs === 'boolean' && config.window.nativeTabs !== this.nativeTabs) {
|
||||
if (isMacintosh && typeof config.window?.nativeTabs === 'boolean' && config.window.nativeTabs !== this.nativeTabs) {
|
||||
this.nativeTabs = config.window.nativeTabs;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// macOS: Native fullscreen
|
||||
if (isMacintosh && config.window && typeof config.window.nativeFullScreen === 'boolean' && config.window.nativeFullScreen !== this.nativeFullScreen) {
|
||||
if (isMacintosh && typeof config.window?.nativeFullScreen === 'boolean' && config.window.nativeFullScreen !== this.nativeFullScreen) {
|
||||
this.nativeFullScreen = config.window.nativeFullScreen;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// macOS: Click through (accept first mouse)
|
||||
if (isMacintosh && config.window && typeof config.window.clickThroughInactive === 'boolean' && config.window.clickThroughInactive !== this.clickThroughInactive) {
|
||||
if (isMacintosh && typeof config.window?.clickThroughInactive === 'boolean' && config.window.clickThroughInactive !== this.clickThroughInactive) {
|
||||
this.clickThroughInactive = config.window.clickThroughInactive;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Update channel
|
||||
if (config.update && typeof config.update.mode === 'string' && config.update.mode !== this.updateMode) {
|
||||
if (typeof config.update?.mode === 'string' && config.update.mode !== this.updateMode) {
|
||||
this.updateMode = config.update.mode;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
// Crash reporter
|
||||
if (config.telemetry && typeof config.telemetry.enableCrashReporter === 'boolean' && config.telemetry.enableCrashReporter !== this.enableCrashReporter) {
|
||||
if (typeof config.telemetry?.enableCrashReporter === 'boolean' && config.telemetry.enableCrashReporter !== this.enableCrashReporter) {
|
||||
this.enableCrashReporter = config.telemetry.enableCrashReporter;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Configuration Sync Auth
|
||||
if (config.configurationSync && typeof config.configurationSync.enableAuth === 'boolean' && config.configurationSync.enableAuth !== this.enableConfigSyncAuth) {
|
||||
if (typeof config.configurationSync?.enableAuth === 'boolean' && config.configurationSync.enableAuth !== this.enableConfigSyncAuth) {
|
||||
this.enableConfigSyncAuth = config.configurationSync.enableAuth;
|
||||
changed = true;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ export class OpenAnythingHandler extends QuickOpenHandler {
|
|||
}
|
||||
|
||||
private updateHandlers(configuration: IWorkbenchSearchConfiguration): void {
|
||||
this.includeSymbols = configuration && configuration.search && configuration.search.quickOpen && configuration.search.quickOpen.includeSymbols;
|
||||
this.includeSymbols = configuration?.search?.quickOpen?.includeSymbols;
|
||||
|
||||
// Files
|
||||
this.openFileHandler.setOptions({
|
||||
|
|
|
@ -96,7 +96,7 @@ class DesktopMain extends Disposable {
|
|||
}
|
||||
|
||||
const filesToWait = this.environmentService.configuration.filesToWait;
|
||||
const filesToWaitPaths = filesToWait && filesToWait.paths;
|
||||
const filesToWaitPaths = filesToWait?.paths;
|
||||
[filesToWaitPaths, this.environmentService.configuration.filesToOpenOrCreate, this.environmentService.configuration.filesToDiff].forEach(paths => {
|
||||
if (Array.isArray(paths)) {
|
||||
paths.forEach(path => {
|
||||
|
|
|
@ -192,7 +192,7 @@ export class ElectronWindow extends Disposable {
|
|||
// High Contrast Events
|
||||
ipc.on('vscode:enterHighContrast', async () => {
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
if (windowConfig && windowConfig.autoDetectHighContrast) {
|
||||
if (windowConfig?.autoDetectHighContrast) {
|
||||
await this.lifecycleService.when(LifecyclePhase.Ready);
|
||||
this.themeService.setColorTheme(VS_HC_THEME, undefined);
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ export class ElectronWindow extends Disposable {
|
|||
|
||||
ipc.on('vscode:leaveHighContrast', async () => {
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
if (windowConfig && windowConfig.autoDetectHighContrast) {
|
||||
if (windowConfig?.autoDetectHighContrast) {
|
||||
await this.lifecycleService.when(LifecyclePhase.Ready);
|
||||
this.themeService.restoreColorTheme();
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ export class ElectronWindow extends Disposable {
|
|||
|
||||
this.openerService.registerExternalUriResolver({
|
||||
resolveExternalUri: async (uri: URI, options?: OpenOptions) => {
|
||||
if (options && options.allowTunneling) {
|
||||
if (options?.allowTunneling) {
|
||||
const portMappingRequest = extractLocalHostUriMetaDataForPortMapping(uri);
|
||||
if (portMappingRequest) {
|
||||
const tunnel = await this.tunnelService.openTunnel(portMappingRequest.port);
|
||||
|
@ -443,7 +443,7 @@ export class ElectronWindow extends Disposable {
|
|||
private shouldOpenExternal(resource: URI, options?: OpenOptions) {
|
||||
const scheme = resource.scheme.toLowerCase();
|
||||
const preferOpenExternal = (scheme === Schemas.mailto || scheme === Schemas.http || scheme === Schemas.https);
|
||||
return (options && options.openExternal) || preferOpenExternal;
|
||||
return options?.openExternal || preferOpenExternal;
|
||||
}
|
||||
|
||||
private updateTouchbarMenu(): void {
|
||||
|
|
|
@ -56,7 +56,7 @@ export class AccessibilityService extends AbstractAccessibilityService implement
|
|||
getAccessibilitySupport(): AccessibilitySupport {
|
||||
if (this._accessibilitySupport === AccessibilitySupport.Unknown) {
|
||||
const config = this.environmentService.configuration;
|
||||
this._accessibilitySupport = (config && config.accessibilitySupport) ? AccessibilitySupport.Enabled : AccessibilitySupport.Disabled;
|
||||
this._accessibilitySupport = config?.accessibilitySupport ? AccessibilitySupport.Enabled : AccessibilitySupport.Disabled;
|
||||
}
|
||||
|
||||
return this._accessibilitySupport;
|
||||
|
|
|
@ -307,7 +307,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
|||
const groupsByLastActive = this.editorGroupService.getGroups(GroupsOrder.MOST_RECENTLY_ACTIVE);
|
||||
|
||||
// Respect option to reveal an editor if it is already visible in any group
|
||||
if (options && options.revealIfVisible) {
|
||||
if (options?.revealIfVisible) {
|
||||
for (const group of groupsByLastActive) {
|
||||
if (group.isActive(input)) {
|
||||
targetGroup = group;
|
||||
|
@ -319,7 +319,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
|||
// Respect option to reveal an editor if it is open (not necessarily visible)
|
||||
// Still prefer to reveal an editor in a group where the editor is active though.
|
||||
if (!targetGroup) {
|
||||
if ((options && options.revealIfOpened) || this.configurationService.getValue<boolean>('workbench.editor.revealIfOpen')) {
|
||||
if (options?.revealIfOpened || this.configurationService.getValue<boolean>('workbench.editor.revealIfOpen')) {
|
||||
let groupWithInputActive: IEditorGroup | undefined = undefined;
|
||||
let groupWithInputOpened: IEditorGroup | undefined = undefined;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ export class TextEditorState {
|
|||
}
|
||||
|
||||
justifiesNewPushState(other: TextEditorState, event?: ICursorPositionChangedEvent): boolean {
|
||||
if (event && event.source === 'api') {
|
||||
if (event?.source === 'api') {
|
||||
return true; // always let API source win (e.g. "Go to definition" should add a history entry)
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ export class HistoryService extends Disposable implements IHistoryService {
|
|||
}
|
||||
|
||||
// Remember as last active editor (can be undefined if none opened)
|
||||
this.lastActiveEditor = activeControl && activeControl.input && activeControl.group ? { editor: activeControl.input, groupId: activeControl.group.id } : undefined;
|
||||
this.lastActiveEditor = activeControl?.input && activeControl.group ? { editor: activeControl.input, groupId: activeControl.group.id } : undefined;
|
||||
|
||||
// Dispose old listeners
|
||||
this.activeEditorListeners.clear();
|
||||
|
@ -596,7 +596,7 @@ export class HistoryService extends Disposable implements IHistoryService {
|
|||
// stack but we need to keep our currentTextEditorState up to date with
|
||||
// the navigtion that occurs.
|
||||
if (this.navigatingInStack) {
|
||||
if (codeEditor && control && control.input) {
|
||||
if (codeEditor && control?.input) {
|
||||
this.currentTextEditorState = new TextEditorState(control.input, codeEditor.getSelection());
|
||||
} else {
|
||||
this.currentTextEditorState = null; // we navigated to a non text editor
|
||||
|
@ -607,7 +607,7 @@ export class HistoryService extends Disposable implements IHistoryService {
|
|||
else {
|
||||
|
||||
// navigation inside text editor
|
||||
if (codeEditor && control && control.input) {
|
||||
if (codeEditor && control?.input) {
|
||||
this.handleTextEditorEvent(control, codeEditor, event);
|
||||
}
|
||||
|
||||
|
@ -615,7 +615,7 @@ export class HistoryService extends Disposable implements IHistoryService {
|
|||
else {
|
||||
this.currentTextEditorState = null; // at this time we have no active text editor view state
|
||||
|
||||
if (control && control.input) {
|
||||
if (control?.input) {
|
||||
this.handleNonTextEditorEvent(control);
|
||||
}
|
||||
}
|
||||
|
@ -849,7 +849,7 @@ export class HistoryService extends Disposable implements IHistoryService {
|
|||
|
||||
const resourceInput = arg2 as IResourceInput;
|
||||
|
||||
return resourceInput && resourceInput.resource.toString() === resource.toString();
|
||||
return resourceInput?.resource.toString() === resource.toString();
|
||||
}
|
||||
|
||||
getHistory(): Array<IEditorInput | IResourceInput> {
|
||||
|
@ -928,7 +928,7 @@ export class HistoryService extends Disposable implements IHistoryService {
|
|||
|
||||
// Editor input: via factory
|
||||
const { editorInputJSON } = serializedEditorHistoryEntry;
|
||||
if (editorInputJSON && editorInputJSON.deserialized) {
|
||||
if (editorInputJSON?.deserialized) {
|
||||
const factory = registry.getEditorInputFactory(editorInputJSON.typeId);
|
||||
if (factory) {
|
||||
const input = factory.deserialize(this.instantiationService, editorInputJSON.deserialized);
|
||||
|
@ -1000,7 +1000,7 @@ export class HistoryService extends Disposable implements IHistoryService {
|
|||
resource = (input as IResourceInput).resource;
|
||||
}
|
||||
|
||||
if (resource && resource.scheme === filterByScheme) {
|
||||
if (resource?.scheme === filterByScheme) {
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ export class BrowserHostService extends Disposable implements IHostService {
|
|||
|
||||
private shouldReuse(options: IOpenWindowOptions = {}): boolean {
|
||||
const windowConfig = this.configurationService.getValue<IWindowSettings>('window');
|
||||
const openFolderInNewWindowConfig = (windowConfig && windowConfig.openFoldersInNewWindow) || 'default' /* default */;
|
||||
const openFolderInNewWindowConfig = windowConfig?.openFoldersInNewWindow || 'default' /* default */;
|
||||
|
||||
let openFolderInNewWindow = !!options.forceNewWindow && !options.forceReuseWindow;
|
||||
if (!options.forceNewWindow && !options.forceReuseWindow && (openFolderInNewWindowConfig === 'on' || openFolderInNewWindowConfig === 'off')) {
|
||||
|
@ -155,7 +155,7 @@ export class BrowserHostService extends Disposable implements IHostService {
|
|||
}
|
||||
|
||||
private async doOpenEmptyWindow(options?: IOpenEmptyWindowOptions): Promise<void> {
|
||||
this.workspaceProvider.open(undefined, { reuse: options && options.forceReuseWindow });
|
||||
this.workspaceProvider.open(undefined, { reuse: options?.forceReuseWindow });
|
||||
}
|
||||
|
||||
async toggleFullScreen(): Promise<void> {
|
||||
|
|
|
@ -82,7 +82,7 @@ export class IntegrityServiceImpl implements IIntegrityService {
|
|||
|
||||
private _prompt(): void {
|
||||
const storedData = this._storage.get();
|
||||
if (storedData && storedData.dontShowPrompt && storedData.commit === product.commit) {
|
||||
if (storedData?.dontShowPrompt && storedData.commit === product.commit) {
|
||||
return; // Do not prompt
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ export class WorkbenchModeServiceImpl extends ModeServiceImpl {
|
|||
mime.clearTextMimes(true /* user configured */);
|
||||
|
||||
// Register based on settings
|
||||
if (configuration.files && configuration.files.associations) {
|
||||
if (configuration.files?.associations) {
|
||||
Object.keys(configuration.files.associations).forEach(pattern => {
|
||||
const langId = configuration.files.associations[pattern];
|
||||
const mimetype = this.getMimeForMode(langId) || `text/x-${langId}`;
|
||||
|
|
|
@ -110,7 +110,7 @@ export class NotificationService extends Disposable implements INotificationServ
|
|||
const toDispose = new DisposableStore();
|
||||
|
||||
// Handle neverShowAgain option accordingly
|
||||
if (options && options.neverShowAgain) {
|
||||
if (options?.neverShowAgain) {
|
||||
const scope = options.neverShowAgain.scope === NeverShowAgainScope.WORKSPACE ? StorageScope.WORKSPACE : StorageScope.GLOBAL;
|
||||
|
||||
// If the user already picked to not show the notification
|
||||
|
@ -163,7 +163,7 @@ export class NotificationService extends Disposable implements INotificationServ
|
|||
|
||||
// Show notification with actions
|
||||
const actions: INotificationActions = { primary: primaryActions, secondary: secondaryActions };
|
||||
handle = this.notify({ severity, message, actions, sticky: options && options.sticky, silent: options && options.silent });
|
||||
handle = this.notify({ severity, message, actions, sticky: options?.sticky, silent: options?.silent });
|
||||
|
||||
Event.once(handle.onDidClose)(() => {
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@ export class ProgressService extends Disposable implements IProgressService {
|
|||
cancelId: buttons.length - 1,
|
||||
keyEventProcessor: (event: StandardKeyboardEvent) => {
|
||||
const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
|
||||
if (resolved && resolved.commandId) {
|
||||
if (resolved?.commandId) {
|
||||
if (allowableCommands.indexOf(resolved.commandId) === -1) {
|
||||
EventHelper.stop(event, true);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ export class BrowserTextFileService extends AbstractTextFileService {
|
|||
|
||||
if (this.fileService.canHandleResource(dirtyResource)) {
|
||||
const model = this.models.get(dirtyResource);
|
||||
hasBackup = !!(model && model.hasBackup());
|
||||
hasBackup = !!(model?.hasBackup());
|
||||
} else if (dirtyResource.scheme === Schemas.untitled) {
|
||||
hasBackup = this.untitledEditorService.hasBackup(dirtyResource);
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
this.autoSaveContext = AutoSaveContext.bindTo(contextKeyService);
|
||||
|
||||
const configuration = configurationService.getValue<IFilesConfiguration>();
|
||||
this.currentFilesAssociationConfig = configuration && configuration.files && configuration.files.associations;
|
||||
this.currentFilesAssociationConfig = configuration?.files?.associations;
|
||||
|
||||
this.onFilesConfigurationChange(configuration);
|
||||
|
||||
|
@ -298,11 +298,11 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
protected onFilesConfigurationChange(configuration: IFilesConfiguration): void {
|
||||
const wasAutoSaveEnabled = (this.getAutoSaveMode() !== AutoSaveMode.OFF);
|
||||
|
||||
const autoSaveMode = (configuration && configuration.files && configuration.files.autoSave) || AutoSaveConfiguration.OFF;
|
||||
const autoSaveMode = configuration?.files?.autoSave || AutoSaveConfiguration.OFF;
|
||||
this.autoSaveContext.set(autoSaveMode);
|
||||
switch (autoSaveMode) {
|
||||
case AutoSaveConfiguration.AFTER_DELAY:
|
||||
this.configuredAutoSaveDelay = configuration && configuration.files && configuration.files.autoSaveDelay;
|
||||
this.configuredAutoSaveDelay = configuration?.files?.autoSaveDelay;
|
||||
this.configuredAutoSaveOnFocusChange = false;
|
||||
this.configuredAutoSaveOnWindowChange = false;
|
||||
break;
|
||||
|
@ -335,14 +335,14 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
}
|
||||
|
||||
// Check for change in files associations
|
||||
const filesAssociation = configuration && configuration.files && configuration.files.associations;
|
||||
const filesAssociation = configuration?.files?.associations;
|
||||
if (!objects.equals(this.currentFilesAssociationConfig, filesAssociation)) {
|
||||
this.currentFilesAssociationConfig = filesAssociation;
|
||||
this._onFilesAssociationChange.fire();
|
||||
}
|
||||
|
||||
// Hot exit
|
||||
const hotExitMode = configuration && configuration.files && configuration.files.hotExit;
|
||||
const hotExitMode = configuration?.files?.hotExit;
|
||||
if (hotExitMode === HotExitConfiguration.OFF || hotExitMode === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
|
||||
this.configuredHotExit = hotExitMode;
|
||||
} else {
|
||||
|
@ -389,7 +389,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
return {
|
||||
...stream,
|
||||
encoding: 'utf8',
|
||||
value: await createTextBufferFactoryFromStream(stream.value, undefined, options && options.acceptTextOnly ? throwOnBinary : undefined)
|
||||
value: await createTextBufferFactoryFromStream(stream.value, undefined, options?.acceptTextOnly ? throwOnBinary : undefined)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -549,7 +549,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
async save(resource: URI, options?: ISaveOptions): Promise<boolean> {
|
||||
|
||||
// Run a forced save if we detect the file is not dirty so that save participants can still run
|
||||
if (options && options.force && this.fileService.canHandleResource(resource) && !this.isDirty(resource)) {
|
||||
if (options?.force && this.fileService.canHandleResource(resource) && !this.isDirty(resource)) {
|
||||
const model = this._models.get(resource);
|
||||
if (model) {
|
||||
options.reason = SaveReason.EXPLICIT;
|
||||
|
@ -835,7 +835,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
// Prefer an existing model if it is already loaded for the given target resource
|
||||
let targetExists: boolean = false;
|
||||
let targetModel = this.models.get(target);
|
||||
if (targetModel && targetModel.isResolved()) {
|
||||
if (targetModel?.isResolved()) {
|
||||
targetExists = true;
|
||||
}
|
||||
|
||||
|
@ -938,7 +938,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
}
|
||||
|
||||
private async doRevertAllFiles(resources?: URI[], options?: IRevertOptions): Promise<ITextFileOperationResult> {
|
||||
const fileModels = options && options.force ? this.getFileModels(resources) : this.getDirtyFileModels(resources);
|
||||
const fileModels = options?.force ? this.getFileModels(resources) : this.getDirtyFileModels(resources);
|
||||
|
||||
const mapResourceToResult = new ResourceMap<IResult>();
|
||||
fileModels.forEach(m => {
|
||||
|
@ -949,7 +949,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
|
||||
await Promise.all(fileModels.map(async model => {
|
||||
try {
|
||||
await model.revert(options && options.soft);
|
||||
await model.revert(options?.soft);
|
||||
|
||||
if (!model.isDirty()) {
|
||||
const result = mapResourceToResult.get(model.getResource());
|
||||
|
|
|
@ -329,8 +329,8 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
|||
}
|
||||
|
||||
private async loadFromFile(options?: ILoadOptions): Promise<TextFileEditorModel> {
|
||||
const forceReadFromDisk = options && options.forceReadFromDisk;
|
||||
const allowBinary = this.isResolved() /* always allow if we resolved previously */ || (options && options.allowBinary);
|
||||
const forceReadFromDisk = options?.forceReadFromDisk;
|
||||
const allowBinary = this.isResolved() /* always allow if we resolved previously */ || options?.allowBinary;
|
||||
|
||||
// Decide on etag
|
||||
let etag: string | undefined;
|
||||
|
@ -436,7 +436,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
|||
} else {
|
||||
type FileGetClassification = {} & FileTelemetryDataFragment;
|
||||
|
||||
this.telemetryService.publicLog2<TelemetryData, FileGetClassification>('fileGet', this.getTelemetryData(options && options.reason ? options.reason : LoadReason.OTHER));
|
||||
this.telemetryService.publicLog2<TelemetryData, FileGetClassification>('fileGet', this.getTelemetryData(options?.reason ?? LoadReason.OTHER));
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -127,7 +127,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
|
|||
// Model exists
|
||||
let model = this.get(resource);
|
||||
if (model) {
|
||||
if (options && options.reload) {
|
||||
if (options?.reload) {
|
||||
|
||||
// async reload: trigger a reload but return immediately
|
||||
if (options.reload.async) {
|
||||
|
@ -198,7 +198,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE
|
|||
this.mapResourceToPendingModelLoaders.delete(resource);
|
||||
|
||||
// Apply mode if provided
|
||||
if (options && options.mode) {
|
||||
if (options?.mode) {
|
||||
resolvedModel.setMode(options.mode);
|
||||
}
|
||||
|
||||
|
|
|
@ -106,12 +106,12 @@ export class NativeTextFileService extends AbstractTextFileService {
|
|||
|
||||
// read through encoding library
|
||||
const decoder = await toDecodeStream(streamToNodeReadable(bufferStream.value), {
|
||||
guessEncoding: (options && options.autoGuessEncoding) || this.textResourceConfigurationService.getValue(resource, 'files.autoGuessEncoding'),
|
||||
guessEncoding: options?.autoGuessEncoding || this.textResourceConfigurationService.getValue(resource, 'files.autoGuessEncoding'),
|
||||
overwriteEncoding: detectedEncoding => this.encoding.getReadEncoding(resource, options, detectedEncoding)
|
||||
});
|
||||
|
||||
// validate binary
|
||||
if (options && options.acceptTextOnly && decoder.detected.seemsBinary) {
|
||||
if (options?.acceptTextOnly && decoder.detected.seemsBinary) {
|
||||
throw new TextFileOperationError(localize('fileBinaryError', "File seems to be binary and cannot be opened as text"), TextFileOperationResult.FILE_IS_BINARY, options);
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ export class NativeTextFileService extends AbstractTextFileService {
|
|||
|
||||
// check for overwriteReadonly property (only supported for local file://)
|
||||
try {
|
||||
if (options && options.overwriteReadonly && resource.scheme === Schemas.file && await exists(resource.fsPath)) {
|
||||
if (options?.overwriteReadonly && resource.scheme === Schemas.file && await exists(resource.fsPath)) {
|
||||
const fileStat = await stat(resource.fsPath);
|
||||
|
||||
// try to change mode to writeable
|
||||
|
@ -174,7 +174,7 @@ export class NativeTextFileService extends AbstractTextFileService {
|
|||
}
|
||||
|
||||
// check for writeElevated property (only supported for local file://)
|
||||
if (options && options.writeElevated && resource.scheme === Schemas.file) {
|
||||
if (options?.writeElevated && resource.scheme === Schemas.file) {
|
||||
return this.writeElevated(resource, value, options);
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ export class NativeTextFileService extends AbstractTextFileService {
|
|||
};
|
||||
|
||||
const sudoCommand: string[] = [`"${this.environmentService.cliPath}"`];
|
||||
if (options && options.overwriteReadonly) {
|
||||
if (options?.overwriteReadonly) {
|
||||
sudoCommand.push('--file-chmod');
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ export class EncodingOracle extends Disposable implements IResourceEncodings {
|
|||
|
||||
// Ensure that we preserve an existing BOM if found for UTF8
|
||||
// unless we are instructed to overwrite the encoding
|
||||
const overwriteEncoding = options && options.overwriteEncoding;
|
||||
const overwriteEncoding = options?.overwriteEncoding;
|
||||
if (!overwriteEncoding && encoding === UTF8) {
|
||||
try {
|
||||
const buffer = (await this.fileService.readFile(resource, { length: UTF8_BOM.length })).value;
|
||||
|
@ -381,7 +381,7 @@ export class EncodingOracle extends Disposable implements IResourceEncodings {
|
|||
let preferredEncoding: string | undefined;
|
||||
|
||||
// Encoding passed in as option
|
||||
if (options && options.encoding) {
|
||||
if (options?.encoding) {
|
||||
if (detectedEncoding === UTF8 && options.encoding === UTF8) {
|
||||
preferredEncoding = UTF8_with_bom; // indicate the file has BOM if we are to resolve with UTF 8
|
||||
} else {
|
||||
|
|
|
@ -238,7 +238,7 @@ export class UntitledEditorService extends Disposable implements IUntitledEditor
|
|||
// Look up default language from settings if any
|
||||
if (!mode && !hasAssociatedFilePath) {
|
||||
const configuration = this.configurationService.getValue<IFilesConfiguration>();
|
||||
if (configuration.files && configuration.files.defaultLanguage) {
|
||||
if (configuration.files?.defaultLanguage) {
|
||||
mode = configuration.files.defaultLanguage;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ export abstract class AbstractWorkspaceEditingService implements IWorkspaceEditi
|
|||
|
||||
protected getCurrentWorkspaceIdentifier(): IWorkspaceIdentifier | undefined {
|
||||
const workspace = this.contextService.getWorkspace();
|
||||
if (workspace && workspace.configuration) {
|
||||
if (workspace?.configuration) {
|
||||
return { id: workspace.id, configPath: workspace.configuration };
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue