diff --git a/CHANGELOG.md b/CHANGELOG.md
index e153f6a..26a9858 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,12 +1,20 @@
# Change Log
-## 1.0.0
-- Initial release
+## 1.1.0
+- Added option to show Favorite folder content (top level files). It is the response to the feature request #1.
+This feature is not a substitution of the Workspace explorer view, which does by far superior job. It's just a convenience measure for a quick access of the top level folder files. The feature can be enabled/disabled with `favorites.showFolderFiles` setting.
-## 1.0.1
-- Updated images
+Note, the feature overall experience is subject to the limitations/defects of the VSCode tree view. These defects are officially reported and being dealt with by the VSCode team:
+https://github.com/Microsoft/vscode/issues/34130
+https://github.com/patrys/vscode-code-outline/issues/24
## 1.0.2
- Added support for folders
- Items icons reflect if file/folder exist or not
- Added context menu for moving items up/down in the list
+
+## 1.0.1
+- Updated images
+
+## 1.0.0
+- Initial release
diff --git a/README.md b/README.md
index 144dece..110b912 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# Favorites - VSCode Extension
Manage and quickly access frequently used files.
-
+
>
This simple extension allows in adding, removing and managing documents in the globally maintained "Favorites" list.
@@ -19,7 +19,15 @@ The functionality is self explanatory and includes following features:
![image](https://raw.githubusercontent.com/oleg-shilo/Favorites.vscode/master/resources/images/favorites_vscode.gif)
-Note: by default VSCode opens any file clicked from the _Favorites_ list in the so called "preview mode". Thus the document tabs are reused and every new file is opened in the same tab. If you prefer to open a clicked _Favorites_ document in ane tab then you need to disable document the previewMode is the settings:
-1. Use _Command Palette_ to open your settings file ("Preferences: Open User Settings")
-2. Add the "workbench.editor.enablePreview" property, and set it's value to _false_.
+The extension also allow showing Favorite folder item content (top level files).
+This feature is not a substitution of the Workspace explorer view, which does by far superior job. It's just a convenience measure for a quick access of the top level folder files. The feature can be enabled/disabled with `favorites.showFolderFiles` setting.
+
+## Limitations
+* _ShowFolderFiles_ feature overall experience is subject to the limitations/defects of the VSCode tree view. These defects are officially reported and being dealt with by the VSCode team:
+https://github.com/Microsoft/vscode/issues/34130
+https://github.com/patrys/vscode-code-outline/issues/24
+
+* By default VSCode opens any file clicked from the _Favorites_ list in the so called "preview mode". Thus the document tabs are reused and every new file is opened in the same tab. If you prefer to open a clicked _Favorites_ document in a new tab then you need to disable document the previewMode is the settings:
+ 1. Use _Command Palette_ to open your settings file ("Preferences: Open User Settings")
+ 2. Add the "workbench.editor.enablePreview" property, and set it's value to _false_.
diff --git a/package.json b/package.json
index 9cf656e..128d3d8 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "favorites",
"displayName": "Favorites",
"description": "Manage and quickly access frequently used documents",
- "version": "1.0.2",
+ "version": "1.1.0",
"publisher": "oleg-shilo",
"engines": {
"vscode": "^1.13.0"
@@ -121,6 +121,17 @@
]
}
},
+ "configuration": {
+ "type": "object",
+ "title": "Favorites configuration",
+ "properties": {
+ "favorites.showFolderFiles": {
+ "type": "boolean",
+ "default": true,
+ "description": "Show folder children. The children are the top-level files present in the folder."
+ }
+ }
+ },
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
diff --git a/src/extension.ts b/src/extension.ts
index d0eb632..e2341df 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -4,19 +4,19 @@ import * as vscode from 'vscode';
import * as os from 'os';
import * as path from 'path';
import * as fs from 'fs';
-import { FavoritesTreeProvider, Dependency } from './tree_view';
+import { FavoritesTreeProvider, FavoriteItem } from './tree_view';
import { Uri, commands } from 'vscode';
function get_favorites_items() {
return Utils.read_all_lines(Utils.fav_file).filter(x => x != '');
}
-function add_workspace(element: Dependency) {
+function add_workspace(element: FavoriteItem) {
if (vscode.workspace.rootPath)
_add(vscode.workspace.rootPath);
}
-function add(element: Dependency) {
+function add(element: FavoriteItem) {
let document = vscode.window.activeTextEditor.document.fileName;
_add(document);
}
@@ -37,7 +37,7 @@ function _add(document: string) {
}
}
-function up(element: Dependency) {
+function up(element: FavoriteItem) {
let lines = Utils.read_all_lines(Utils.fav_file).filter(x => x != '');
@@ -52,7 +52,7 @@ function up(element: Dependency) {
commands.executeCommand('favorites.refresh');
}
-function down(element: Dependency) {
+function down(element: FavoriteItem) {
let lines = Utils.read_all_lines(Utils.fav_file).filter(x => x != '');
@@ -67,7 +67,7 @@ function down(element: Dependency) {
commands.executeCommand('favorites.refresh');
}
-function remove(element: Dependency) {
+function remove(element: FavoriteItem) {
let lines: string[] = [];
Utils.read_all_lines(Utils.fav_file)
@@ -111,7 +111,7 @@ class Utils {
Utils._fav_file = Utils.ensure_fav_file();
return Utils._fav_file;
}
-
+
public static read_all_lines(file: string): string[] {
let text = fs.readFileSync(file, 'utf8');
return text.split(/\r?\n/g);
diff --git a/src/tree_view.ts b/src/tree_view.ts
index 536ea65..e1c5dc8 100644
--- a/src/tree_view.ts
+++ b/src/tree_view.ts
@@ -3,10 +3,10 @@ import * as fs from 'fs';
import * as path from 'path';
import { Uri, commands } from "vscode";
-export class FavoritesTreeProvider implements vscode.TreeDataProvider {
+export class FavoritesTreeProvider implements vscode.TreeDataProvider {
- private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter();
- readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event;
+ private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter();
+ readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event;
constructor(private aggregateItems: () => string[]) {
vscode.window.onDidChangeActiveTextEditor(editor => {
@@ -21,21 +21,41 @@ export class FavoritesTreeProvider implements vscode.TreeDataProvider {
+ getChildren(element?: FavoriteItem): Thenable {
return new Promise(resolve => {
if (element) {
- resolve([]);
+ let nodes = [];
+ let dir = element.context;
+ fs.readdirSync(dir).forEach(fileName => {
+ var file = path.join(dir, fileName);
+ if (fs.lstatSync(file).isFile()) {
+ let node = new FavoriteItem(
+ fileName,
+ vscode.TreeItemCollapsibleState.None,
+ {
+ command: 'vscode.open',
+ title: '',
+ tooltip: file,
+ arguments: [Uri.file(file)],
+ },
+ null,
+ file
+ );
+ nodes.push(node);
+ }
+ })
+ resolve(nodes);
} else {
resolve(this.getScriptItems());
}
});
}
- private getScriptItems(): Dependency[] {
+ private getScriptItems(): FavoriteItem[] {
let nodes = [];
@@ -44,19 +64,23 @@ export class FavoritesTreeProvider implements vscode.TreeDataProvider