Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added doc/7-fuzzy-search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions img/haskell-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -91,6 +96,11 @@
}
],
"view/title": [
{
"command": "haskell-modules.search",
"group": "navigation",
"when": "view == haskell-modules"
},
{
"command": "haskell-modules.refresh",
"group": "navigation",
Expand Down Expand Up @@ -150,5 +160,5 @@
"watch": "webpack --watch",
"watch-tests": "tsc -p . -w --outDir out"
},
"version": "1.0.1"
"version": "1.1.0"
}
33 changes: 33 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export type Commands = {
/** Search the workspace for Haskell module files. */
populate: () => Promise<boolean>

/** Fuzzy search for a module and open it. */
searchModules: () => Promise<boolean>

/** Add a submodule to the given module. */
addSubmodule: (m: Module) => Promise<boolean>

Expand Down Expand Up @@ -159,6 +162,35 @@ export namespace Commands {
return true
}

async function searchModules(): Promise<boolean> {
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<boolean> {
const tell = tells('addSubmodule')
tell(undefined, m)
Expand Down Expand Up @@ -321,6 +353,7 @@ export namespace Commands {

return {
populate,
searchModules,
addSubmodule,
createModuleFile,
renameModule,
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async function initProvider(): Promise<vscode.Disposable> {

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),
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type Index = {
getByEditor(uri: vscode.TextEditor): Module | undefined
getChildren(parent?: Module): Array<Module>
getParent(child: Module): Module | undefined
getAll(): Array<Module>
getSourceDirs(): Array<string>
insert(module: Module): void
}
Expand Down Expand Up @@ -58,6 +59,10 @@ export namespace Index {
: undefined
}

function getAll(): Array<Module> {
return [...modules.values()].filter(m => m.uri !== undefined)
}

function getSourceDirs(): Array<string> {
return [...sourcedirs].sort()
}
Expand All @@ -80,6 +85,6 @@ export namespace Index {
}
}

return { get, getByFilePath, getByEditor, getChildren, getParent, getSourceDirs, insert }
return { get, getByFilePath, getByEditor, getChildren, getParent, getAll, getSourceDirs, insert }
}
}