Skip to content

Commit 1d3fafb

Browse files
authored
Merge pull request #7 from martinRenou/single_click_toggle_dir
Single click to toggle directories
2 parents 5071270 + 6151407 commit 1d3fafb

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/unfold.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,24 +218,17 @@ export class DirTreeListing extends DirListing {
218218
return this._model;
219219
}
220220

221-
protected handleOpen(item: Contents.IModel): void {
222-
if (item.type === 'directory') {
223-
this.model.toggle(item.path);
224-
} else {
225-
super.handleOpen(item);
226-
}
227-
}
228-
229221
protected async handleFileSelect(event: MouseEvent): Promise<void> {
230222
super.handleFileSelect(event);
231223

232224
if (Object.keys(this.selection).length === 1) {
233225
const selection = Object.keys(this.selection)[0];
234226

235-
const isDirectory = await this.model.isDirectory(selection);
227+
const entry = await this.model.getEntry(selection);
236228

237-
if (isDirectory) {
229+
if (entry.type === 'directory') {
238230
this.model.path = '/' + selection;
231+
this.model.toggle(entry.path);
239232
} else {
240233
this.model.path = '/' + PathExt.dirname(selection);
241234
}
@@ -407,10 +400,8 @@ export class FilterFileTreeBrowserModel extends FilterFileBrowserModel {
407400
this._path = value;
408401
}
409402

410-
async isDirectory(path: string): Promise<boolean> {
411-
const entry = await this.contentManager.get(path);
412-
413-
return entry.type === 'directory';
403+
async getEntry(path: string): Promise<Contents.IModel> {
404+
return await this.contentManager.get(path);
414405
}
415406

416407
/**

0 commit comments

Comments
 (0)