diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aa6bef..b6c24ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to the "haskell-modules" extension will be documented in thi Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. +## [1.1.0] + +- Add fuzzy search for modules via Quick Pick menu +- New command `Haskell Modules: Search module...` accessible from the view title bar +- Fix missing icon in the activity bar + ## [1.0.1] - Fix bug that prevented parsing of config path `haskell-modules.excludesRegEx` diff --git a/README.md b/README.md index 773de4a..782375b 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,12 @@ can find. Extension ID `haskell-modules`. Published by `friedbrice`. ![Jump to modules](doc/5-jump-to-module.gif) +* __Fuzzy search modules__ Quickly find and open any module in your workspace + using fuzzy search. Access it via the search icon in the module tree view + or the command palette (`Haskell Modules: Search module...`). + + ![Fuzzy search for modules](doc/7-fuzzy-search.png) + * __Hydrate/Dehydrate module__ Inserts qualified imports of all imported modules (hydrate). This greatly improves GHC feedback and suggestions. When done working on a module, qualified symbols introduced in this way can diff --git a/doc/7-fuzzy-search.png b/doc/7-fuzzy-search.png new file mode 100644 index 0000000..8f3ae67 Binary files /dev/null and b/doc/7-fuzzy-search.png differ diff --git a/img/haskell-icon.svg b/img/haskell-icon.svg new file mode 100644 index 0000000..e5d669d --- /dev/null +++ b/img/haskell-icon.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/package.json b/package.json index f2cff2a..c1be51f 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,11 @@ "icon": "$(sync)", "title": "Haskell Modules: Refresh" }, + { + "command": "haskell-modules.search", + "icon": "$(search)", + "title": "Haskell Modules: Search module..." + }, { "command": "haskell-modules.add", "icon": "$(add)", @@ -91,6 +96,11 @@ } ], "view/title": [ + { + "command": "haskell-modules.search", + "group": "navigation", + "when": "view == haskell-modules" + }, { "command": "haskell-modules.refresh", "group": "navigation", @@ -150,5 +160,5 @@ "watch": "webpack --watch", "watch-tests": "tsc -p . -w --outDir out" }, - "version": "1.0.1" + "version": "1.1.0" } diff --git a/src/commands.ts b/src/commands.ts index b31f5f5..567b9c5 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -9,6 +9,9 @@ export type Commands = { /** Search the workspace for Haskell module files. */ populate: () => Promise + /** Fuzzy search for a module and open it. */ + searchModules: () => Promise + /** Add a submodule to the given module. */ addSubmodule: (m: Module) => Promise @@ -159,6 +162,35 @@ export namespace Commands { return true } + async function searchModules(): Promise { + const tell = tells('searchModules') + tell('Listing all modules..') + + const modules = index.getAll() + const items = modules.map(m => { + let label = m.id + if (m.name[0] === 'Main' && m.uri) { + label = `Main (${vscode.workspace.asRelativePath(m.uri)})` + } + return { + label, + description: m.uri ? vscode.workspace.asRelativePath(m.uri) : undefined, + module: m + } + }) + + const selected = await vscode.window.showQuickPick(items, { + placeHolder: 'Search for a module to open...' + }) + + if (selected && selected.module.uri) { + tell('Selected module', selected.module) + await vscode.window.showTextDocument(selected.module.uri) + } + + return populate() + } + async function addSubmodule(m: Module): Promise { const tell = tells('addSubmodule') tell(undefined, m) @@ -321,6 +353,7 @@ export namespace Commands { return { populate, + searchModules, addSubmodule, createModuleFile, renameModule, diff --git a/src/extension.ts b/src/extension.ts index e633d8c..23a3f6a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -79,6 +79,7 @@ async function initProvider(): Promise { disposables.push( vscode.commands.registerCommand('haskell-modules.refresh', commands.populate), + vscode.commands.registerCommand('haskell-modules.search', commands.searchModules), vscode.commands.registerCommand('haskell-modules.add', commands.addSubmodule), vscode.commands.registerCommand('haskell-modules.create', commands.createModuleFile), vscode.commands.registerCommand('haskell-modules.rename', commands.renameModule), diff --git a/src/index.ts b/src/index.ts index e12826b..511f499 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,7 @@ export type Index = { getByEditor(uri: vscode.TextEditor): Module | undefined getChildren(parent?: Module): Array getParent(child: Module): Module | undefined + getAll(): Array getSourceDirs(): Array insert(module: Module): void } @@ -58,6 +59,10 @@ export namespace Index { : undefined } + function getAll(): Array { + return [...modules.values()].filter(m => m.uri !== undefined) + } + function getSourceDirs(): Array { return [...sourcedirs].sort() } @@ -80,6 +85,6 @@ export namespace Index { } } - return { get, getByFilePath, getByEditor, getChildren, getParent, getSourceDirs, insert } + return { get, getByFilePath, getByEditor, getChildren, getParent, getAll, getSourceDirs, insert } } }