Skip to content

Commit

Permalink
Address PR Comments
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
  • Loading branch information
tsmaeder committed Jan 19, 2023
1 parent 90a5861 commit 312b816
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
- [plugin] added support for `isTransient` of `TerminalOptions` and `ExternalTerminalOptions` VS Code API [#12055](https://github.com/eclipse-theia/theia/pull/12055) - Contributed on behalf of STMicroelectronics
- [terminal] added support for preference `terminal.integrated.enablePersistentSessions` to allow disabling restoring terminals on reload [#12055](https://github.com/eclipse-theia/theia/pull/12055) - Contributed on behalf of STMicroelectronics

<a name="breaking_changes_1.34.0">[Breaking Changes:](#breaking_changes_1.34.0)</a>

- [plugin-ext] Renamed `TreeViewWidgetIdentifier` to `TreeViewWidgetOptions` as there were more fields added to it. [12065](https://github.com/eclipse-theia/theia/pull/12065)
## v1.33.0 - 12/20/2022

- [application-package] added support for declaring extensions as peer dependencies [#11808](https://github.com/eclipse-theia/theia/pull/11808)
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/shell/application-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,13 @@ export class ApplicationShell extends Widget {
this.additionalDraggedUris = undefined;
}

static getDraggedEditorUris(dataTransfer: DataTransfer): URI[] {
protected static getDraggedEditorUris(dataTransfer: DataTransfer): URI[] {
const data = dataTransfer.getData('theia-editor-dnd');
return data ? data.split('\n').map(entry => new URI(entry)) : [];
}

static setDraggedEditorUris(dataTransfer: DataTransfer, uris: URI[]): void {
dataTransfer.setData('theia-editor-dnd', uris.map(uri => uri.toString()).join('\r\n'));
dataTransfer.setData('theia-editor-dnd', uris.map(uri => uri.toString()).join('\n'));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// *****************************************************************************
// Copyright (C) 2022 ST Microelectronics and others.
// Copyright (C) 2022 STMicroelectronics and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -18,8 +18,9 @@ import { injectable } from '@theia/core/shared/inversify';

@injectable()
export class DnDFileContentStore {
static id: number = 0;
private static id: number = 0;
private files: Map<string, File> = new Map();

addFile(f: File): string {
const id = (DnDFileContentStore.id++).toString();
this.files.set(id, f);
Expand Down
26 changes: 13 additions & 13 deletions packages/plugin-ext/src/main/browser/view/tree-view-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { ACTION_ITEM, Widget } from '@theia/core/lib/browser/widgets/widget';
import { Emitter, Event } from '@theia/core/lib/common/event';
import { MessageService } from '@theia/core/lib/common/message-service';
import { View } from '../../../common/plugin-protocol';
import CoreURI, { URI } from '@theia/core/lib/common/uri';
import { URI } from '@theia/core/lib/common/uri';
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
import { MarkdownString } from '@theia/core/lib/common/markdown-rendering';
import { LabelParser } from '@theia/core/lib/browser/label-parser';
Expand Down Expand Up @@ -427,7 +427,7 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
protected readonly dndFileContentStore: DnDFileContentStore;

protected treeDragType: string;
expansionTimeouts: Map<string, number> = new Map();
protected readonly expansionTimeouts: Map<string, number> = new Map();

@postConstruct()
protected override init(): void {
Expand Down Expand Up @@ -511,7 +511,7 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
});
} else {
const title = node.tooltip ||
(node.resourceUri && this.labelProvider.getLongName(new CoreURI(node.resourceUri)))
(node.resourceUri && this.labelProvider.getLongName(new URI(node.resourceUri)))
|| this.toNodeName(node);
event.currentTarget.title = title;
}
Expand All @@ -531,7 +531,7 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
};
} else {
const title = node.tooltip ||
(node.resourceUri && this.labelProvider.getLongName(new CoreURI(node.resourceUri)))
(node.resourceUri && this.labelProvider.getLongName(new URI(node.resourceUri)))
|| this.toNodeName(node);

attrs = {
Expand Down Expand Up @@ -624,7 +624,7 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {

this.model.proxy!.$dragStarted(this.options.id, selectedNodes.map(selected => selected.id), CancellationToken.None).then(maybeUris => {
if (maybeUris) {
this.applicationShell.addAdditionalDraggedEditorUris(maybeUris.map(CoreURI.fromComponents));
this.applicationShell.addAdditionalDraggedEditorUris(maybeUris.map(URI.fromComponents));
}
});
}
Expand All @@ -635,9 +635,9 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {

handleDragOver(event: React.DragEvent<HTMLElement>): void {
if (event.dataTransfer) {
const canDrop = event.dataTransfer.types.some(type => event.dataTransfer.types.indexOf(type) >= 0) ||
event.dataTransfer.types.indexOf(this.treeDragType) > 0 ||
this.options.dropMimeTypes!.indexOf('files') > 0 && event.dataTransfer.files.length > 0;
const canDrop = event.dataTransfer.types.some(type => this.options.dropMimeTypes!.includes(type)) ||
event.dataTransfer.types.includes(this.treeDragType) ||
this.options.dropMimeTypes!.includes('files') && event.dataTransfer.files.length > 0;
if (canDrop) {
event.preventDefault();
event.dataTransfer.dropEffect = 'move';
Expand Down Expand Up @@ -677,21 +677,21 @@ export class TreeViewWidget extends TreeViewWelcomeWidget {
}
}
}
if (items.length > 0 || event.dataTransfer.types.indexOf(this.treeDragType) >= 0) {
if (items.length > 0 || event.dataTransfer.types.includes(this.treeDragType)) {
event.preventDefault();
event.stopPropagation();
const filesCopy = [...files];
this.model.proxy?.$drop(this.id, node?.id, items, CancellationToken.None).then(() => {
for (const file of filesCopy) {
this.model.proxy?.$drop(this.id, node?.id, items, CancellationToken.None).finally(() => {
for (const file of files) {
this.dndFileContentStore.removeFile(file);
}
});
files = [];
}
} finally {
} catch (e) {
for (const file of files) {
this.dndFileContentStore.removeFile(file);
}
throw e;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/plugin-ext/src/main/browser/view/tree-views-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ export class TreeViewsMainImpl implements TreeViewsMain, Disposable {
this.toDispose.dispose();
}

async $registerTreeDataProvider(treeViewId: string, dragMimetypes: string[] | undefined, dropMimetypes: string[] | undefined): Promise<void> {
async $registerTreeDataProvider(treeViewId: string, dragMimeTypes: string[] | undefined, dropMimeTypes: string[] | undefined): Promise<void> {
this.treeViewProviders.set(treeViewId, this.viewRegistry.registerViewDataProvider(treeViewId, async ({ state, viewInfo }) => {
const options: TreeViewWidgetOptions = {
id: treeViewId,
dragMimeTypes: dragMimetypes,
dropMimeTypes: dropMimetypes
dragMimeTypes,
dropMimeTypes
};

const widget = await this.widgetManager.getOrCreateWidget<TreeViewWidget>(PLUGIN_VIEW_DATA_FACTORY_ID, options);
Expand Down

0 comments on commit 312b816

Please sign in to comment.