mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-04-01 01:20:31 -04:00
Merge from vscode 011858832762aaff245b2336fb1c38166e7a10fb (#4663)
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
import * as nls from 'vs/nls';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as perf from 'vs/base/common/performance';
|
||||
import { sequence } from 'vs/base/common/async';
|
||||
import { Action, IAction } from 'vs/base/common/actions';
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
import { IFilesConfiguration, ExplorerFolderContext, FilesExplorerFocusedContext, ExplorerFocusedContext, ExplorerRootContext, ExplorerResourceReadonlyContext, IExplorerService, ExplorerResourceCut } from 'vs/workbench/contrib/files/common/files';
|
||||
@@ -49,6 +48,9 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
|
||||
import { isMacintosh } from 'vs/base/common/platform';
|
||||
import { KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { isEqualOrParent } from 'vs/base/common/resources';
|
||||
import { values } from 'vs/base/common/map';
|
||||
import { first } from 'vs/base/common/arrays';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
|
||||
export class ExplorerView extends ViewletPanel {
|
||||
@@ -188,7 +190,7 @@ export class ExplorerView extends ViewletPanel {
|
||||
this.tree.domFocus();
|
||||
}
|
||||
}));
|
||||
this.disposables.push(this.explorerService.onDidSelectItem(e => this.onSelectItem(e.item, e.reveal)));
|
||||
this.disposables.push(this.explorerService.onDidSelectResource(e => this.onSelectResource(e.resource, e.reveal)));
|
||||
this.disposables.push(this.explorerService.onDidCopyItems(e => this.onCopyItems(e.items, e.cut, e.previouslyCutItems)));
|
||||
|
||||
// Update configuration
|
||||
@@ -507,27 +509,27 @@ export class ExplorerView extends ViewletPanel {
|
||||
return withNullAsUndefined(toResource(input, { supportSideBySide: true }));
|
||||
}
|
||||
|
||||
private onSelectItem(fileStat: ExplorerItem | undefined, reveal = this.autoReveal): Promise<void> {
|
||||
if (!fileStat || !this.isBodyVisible() || this.tree.getInput() === fileStat) {
|
||||
return Promise.resolve(undefined);
|
||||
private async onSelectResource(resource: URI | undefined, reveal = this.autoReveal): Promise<void> {
|
||||
if (!resource || !this.isBodyVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Expand all stats in the parent chain
|
||||
const toExpand: ExplorerItem[] = [];
|
||||
let parent = fileStat.parent;
|
||||
while (parent) {
|
||||
toExpand.push(parent);
|
||||
parent = parent.parent;
|
||||
let item: ExplorerItem | undefined = this.explorerService.roots.filter(i => isEqualOrParent(resource, i.resource))[0];
|
||||
|
||||
while (item && item.resource.toString() !== resource.toString()) {
|
||||
await this.tree.expand(item);
|
||||
item = first(values(item.children), i => isEqualOrParent(resource, i.resource));
|
||||
}
|
||||
|
||||
return sequence(toExpand.reverse().map(s => () => this.tree.expand(s))).then(() => {
|
||||
if (item && item.parent) {
|
||||
if (reveal) {
|
||||
this.tree.reveal(fileStat, 0.5);
|
||||
this.tree.reveal(item, 0.5);
|
||||
}
|
||||
|
||||
this.tree.setFocus([fileStat]);
|
||||
this.tree.setSelection([fileStat]);
|
||||
});
|
||||
this.tree.setFocus([item]);
|
||||
this.tree.setSelection([item]);
|
||||
}
|
||||
}
|
||||
|
||||
private onCopyItems(stats: ExplorerItem[], cut: boolean, previousCut: ExplorerItem[] | undefined): void {
|
||||
|
||||
@@ -9,7 +9,7 @@ import * as glob from 'vs/base/common/glob';
|
||||
import { IListVirtualDelegate, ListDragOverEffect } from 'vs/base/browser/ui/list/list';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IFileService, FileKind, IFileStat, FileOperationError, FileOperationResult } from 'vs/platform/files/common/files';
|
||||
import { IFileService, FileKind, FileOperationError, FileOperationResult } from 'vs/platform/files/common/files';
|
||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { IDisposable, Disposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
|
||||
@@ -63,10 +63,11 @@ export class ExplorerDelegate implements IListVirtualDelegate<ExplorerItem> {
|
||||
export class ExplorerDataSource implements IAsyncDataSource<ExplorerItem | ExplorerItem[], ExplorerItem> {
|
||||
|
||||
constructor(
|
||||
@IProgressService private progressService: IProgressService,
|
||||
@INotificationService private notificationService: INotificationService,
|
||||
@IWorkbenchLayoutService private layoutService: IWorkbenchLayoutService,
|
||||
@IFileService private fileService: IFileService
|
||||
@IProgressService private readonly progressService: IProgressService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IExplorerService private readonly explorerService: IExplorerService
|
||||
) { }
|
||||
|
||||
hasChildren(element: ExplorerItem | ExplorerItem[]): boolean {
|
||||
@@ -78,7 +79,7 @@ export class ExplorerDataSource implements IAsyncDataSource<ExplorerItem | Explo
|
||||
return Promise.resolve(element);
|
||||
}
|
||||
|
||||
const promise = element.fetchChildren(this.fileService).then(undefined, e => {
|
||||
const promise = element.fetchChildren(this.fileService, this.explorerService).then(undefined, e => {
|
||||
// Do not show error for roots since we already use an explorer decoration to notify user
|
||||
if (!(element instanceof ExplorerItem && element.isRoot)) {
|
||||
this.notificationService.error(e);
|
||||
@@ -635,12 +636,12 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
|
||||
if (resources && resources.length > 0) {
|
||||
|
||||
// Resolve target to check for name collisions and ask user
|
||||
return this.fileService.resolveFile(target.resource).then((targetStat: IFileStat) => {
|
||||
return this.fileService.resolveFile(target.resource).then(targetStat => {
|
||||
|
||||
// Check for name collisions
|
||||
const targetNames = new Set<string>();
|
||||
if (targetStat.children) {
|
||||
targetStat.children.forEach((child) => {
|
||||
targetStat.children.forEach(child => {
|
||||
targetNames.add(isLinux ? child.name : child.name.toLowerCase());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user