Skip to content

Commit

Permalink
GH-1479: Fixed bug when moving Files from left to right.
Browse files Browse the repository at this point in the history
Also reused disposables from the parent widget.

Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
kittaakos committed Mar 16, 2018
1 parent e50be0f commit 9ca393b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
12 changes: 4 additions & 8 deletions packages/navigator/src/browser/navigator-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { FileTreeWidget, DirNode } from '@theia/filesystem/lib/browser';
import { WorkspaceService, WorkspaceCommands } from '@theia/workspace/lib/browser';
import { FileNavigatorModel } from './navigator-model';
import { FileNavigatorSearch } from './navigator-search';
import { DisposableCollection } from '@theia/core/lib/common/disposable';
import { SearchBoxWidget, SearchBoxWidgetProps, SearchBoxWidgetFactory } from './search-box-widget';

export const FILE_NAVIGATOR_ID = 'files';
Expand All @@ -25,7 +24,6 @@ export const CLASS = 'theia-Files';
@injectable()
export class FileNavigatorWidget extends FileTreeWidget {

protected readonly disposables = new DisposableCollection();
protected readonly searchBox: SearchBoxWidget;

constructor(
Expand All @@ -45,7 +43,7 @@ export class FileNavigatorWidget extends FileTreeWidget {
this.addClass(CLASS);
this.initialize();
this.searchBox = searchBoxFactory(SearchBoxWidgetProps.DEFAULT);
this.disposables.pushAll([
this.toDispose.pushAll([
this.model.onExpansionChanged(() => this.searchBox.hide()),
this.navigatorSearch,
this.navigatorSearch.onFilteredNodesChanged(nodes => {
Expand Down Expand Up @@ -79,11 +77,6 @@ export class FileNavigatorWidget extends FileTreeWidget {
});
}

dispose(): void {
super.dispose();
this.disposables.dispose();
}

protected deflateForStorage(node: TreeNode): object {
// tslint:disable-next-line:no-any
const copy = { ...node } as any;
Expand All @@ -109,6 +102,9 @@ export class FileNavigatorWidget extends FileTreeWidget {
super.onAfterAttach(msg);
this.addClipboardListener(this.node, 'copy', e => this.handleCopy(e));
this.addClipboardListener(this.node, 'paste', e => this.handlePaste(e));
if (this.searchBox.isAttached) {
Widget.detach(this.searchBox);
}
Widget.attach(this.searchBox, this.node.parentElement!);
this.addKeyListener(this.node, this.searchBox.keyCodePredicate.bind(this.searchBox), this.searchBox.handle.bind(this.searchBox));
}
Expand Down
8 changes: 1 addition & 7 deletions packages/navigator/src/browser/search-box-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { inject, injectable } from 'inversify';
import { KeyCode, Key } from '@theia/core/lib/browser';
import { BaseWidget } from '@theia/core/lib/browser/widgets/widget';
import { Event, Emitter } from '@theia/core/lib/common/event';
import { DisposableCollection } from '@theia/core/lib/common/disposable';
import { SearchThrottle } from './search-throttle';

/**
Expand Down Expand Up @@ -52,7 +51,6 @@ export class SearchBoxWidget extends BaseWidget {
Key.BACKSPACE
];

protected readonly disposables = new DisposableCollection();
protected readonly nextEmitter = new Emitter<void>();
protected readonly previousEmitter = new Emitter<void>();
protected readonly closeEmitter = new Emitter<void>();
Expand All @@ -64,7 +62,7 @@ export class SearchBoxWidget extends BaseWidget {
@inject(SearchThrottle) protected readonly throttle: SearchThrottle) {

super();
this.disposables.pushAll([
this.toDispose.pushAll([
this.nextEmitter,
this.previousEmitter,
this.closeEmitter,
Expand All @@ -78,10 +76,6 @@ export class SearchBoxWidget extends BaseWidget {
this.input = input;
}

dispose() {
this.disposables.dispose();
}

get onPrevious(): Event<void> {
return this.previousEmitter.event;
}
Expand Down

0 comments on commit 9ca393b

Please sign in to comment.