Merge from vscode de81ccf04849309f843db21130c806a5783678f7 (#4738)

This commit is contained in:
Anthony Dresser
2019-03-28 13:06:16 -07:00
committed by GitHub
parent cc2951265e
commit e6785ffe95
77 changed files with 562 additions and 835 deletions

View File

@@ -42,7 +42,7 @@ import { Constants } from 'vs/editor/common/core/uint';
import { CLOSE_EDITORS_AND_GROUP_COMMAND_ID } from 'vs/workbench/browser/parts/editor/editorCommands';
import { coalesce } from 'vs/base/common/arrays';
import { AsyncDataTree } from 'vs/base/browser/ui/tree/asyncDataTree';
import { ExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
import { ExplorerItem, NewExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
import { onUnexpectedError } from 'vs/base/common/errors';
import { sequence } from 'vs/base/common/async';
@@ -100,7 +100,6 @@ export class BaseErrorReportingAction extends Action {
}
}
const PLACEHOLDER_URI = URI.file('');
function refreshIfSeparator(value: string, explorerService: IExplorerService): void {
if (value && ((value.indexOf('/') >= 0) || (value.indexOf('\\') >= 0))) {
// New input contains separator, multiple resources will get created workaround for #68204
@@ -143,7 +142,7 @@ export class NewFileAction extends BaseErrorReportingAction {
return Promise.reject(new Error('Parent folder is readonly.'));
}
const stat = new ExplorerItem(PLACEHOLDER_URI, folder, false);
const stat = new NewExplorerItem(folder, false);
return folder.fetchChildren(this.fileService, this.explorerService).then(() => {
folder.addChild(stat);
@@ -211,7 +210,7 @@ export class NewFolderAction extends BaseErrorReportingAction {
return Promise.reject(new Error('Parent folder is readonly.'));
}
const stat = new ExplorerItem(PLACEHOLDER_URI, folder, true);
const stat = new NewExplorerItem(folder, true);
return folder.fetchChildren(this.fileService, this.explorerService).then(() => {
folder.addChild(stat);

View File

@@ -36,10 +36,6 @@ export class ExplorerDecorationsProvider implements IDecorationsProvider {
return this._onDidChange.event;
}
changed(uris: URI[]): void {
this._onDidChange.fire(uris);
}
provideDecorations(resource: URI): IDecorationData | undefined {
const fileStat = this.explorerService.findClosest(resource);
if (fileStat && fileStat.isRoot && fileStat.isError) {

View File

@@ -37,7 +37,7 @@ import { ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/tree';
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
import { ExplorerItem, NewExplorerItem } from 'vs/workbench/contrib/files/common/explorerModel';
import { onUnexpectedError } from 'vs/base/common/errors';
import { ResourceLabels, IResourceLabelsContainer } from 'vs/workbench/browser/labels';
import { createFileIconThemableTreeContainerScope } from 'vs/workbench/browser/parts/views/views';
@@ -45,9 +45,6 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
import { IAsyncDataTreeViewState } from 'vs/base/browser/ui/tree/asyncDataTree';
import { FuzzyScore } from 'vs/base/common/filters';
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';
@@ -68,7 +65,6 @@ export class ExplorerView extends ViewletPanel {
// Refresh is needed on the initial explorer open
private shouldRefresh = true;
private dragHandler: DelayedDragHandler;
private decorationProvider: ExplorerDecorationsProvider;
private autoReveal = false;
constructor(
@@ -99,9 +95,9 @@ export class ExplorerView extends ViewletPanel {
this.readonlyContext = ExplorerResourceReadonlyContext.bindTo(contextKeyService);
this.rootContext = ExplorerRootContext.bindTo(contextKeyService);
this.decorationProvider = new ExplorerDecorationsProvider(this.explorerService, contextService);
decorationService.registerDecorationsProvider(this.decorationProvider);
this.disposables.push(this.decorationProvider);
const decorationProvider = new ExplorerDecorationsProvider(this.explorerService, contextService);
decorationService.registerDecorationsProvider(decorationProvider);
this.disposables.push(decorationProvider);
this.disposables.push(this.resourceContext);
}
@@ -285,7 +281,13 @@ export class ExplorerView extends ViewletPanel {
accessibilityProvider: new ExplorerAccessibilityProvider(),
ariaLabel: nls.localize('treeAriaLabel', "Files Explorer"),
identityProvider: {
getId: (stat: ExplorerItem) => stat.resource
getId: (stat: ExplorerItem) => {
if (stat instanceof NewExplorerItem) {
return `new:${stat.resource}`;
}
return stat.resource;
}
},
keyboardNavigationLabelProvider: {
getKeyboardNavigationLabel: (stat: ExplorerItem) => {
@@ -338,17 +340,6 @@ export class ExplorerView extends ViewletPanel {
}));
this.disposables.push(this.tree.onContextMenu(e => this.onContextMenu(e)));
this.disposables.push(this.tree.onKeyDown(e => {
const event = new StandardKeyboardEvent(e);
const toggleCollapsed = isMacintosh ? (event.keyCode === KeyCode.DownArrow && event.metaKey) : event.keyCode === KeyCode.Enter;
if (toggleCollapsed && !this.explorerService.isEditable(undefined)) {
const focus = this.tree.getFocus();
if (focus.length === 1 && focus[0].isDirectory) {
this.tree.toggleCollapsed(focus[0]);
}
}
}));
// save view state on shutdown
this.storageService.onWillSaveState(() => {

View File

@@ -222,7 +222,8 @@ export class FilesRenderer implements ITreeRenderer<ExplorerItem, FuzzyScore, IF
const value = inputBox.value;
dispose(toDispose);
container.removeChild(label.element);
editableData.onFinish(value, success);
// Timeout: once done rendering only then re-render #70902
setTimeout(() => editableData.onFinish(value, success), 0);
});
let ignoreDisposeAndBlur = true;
@@ -252,7 +253,7 @@ export class FilesRenderer implements ITreeRenderer<ExplorerItem, FuzzyScore, IF
return toDisposable(() => {
if (!ignoreDisposeAndBlur) {
blurDisposable.dispose();
done(inputBox.isInputValid());
done(false);
}
});
}
@@ -781,7 +782,7 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
rootsToMove.push(data);
}
}
if (!targetIndex) {
if (targetIndex === undefined) {
targetIndex = workspaceCreationData.length;
}
@@ -804,6 +805,10 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
// Otherwise move
const targetResource = joinPath(target.resource, source.name);
if (source.isReadonly) {
// Do not allow moving readonly items
return Promise.resolve();
}
return this.textFileService.move(source.resource, targetResource).then(undefined, error => {