Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
Add VSCode QuickOpen Scoring/Sorting (#2009)
Browse files Browse the repository at this point in the history
* Add VSCode files for now.

* Hook up to current regex method.

* Fix or ignore lint issues.

* Swap to using scoreItem and add Oni wrapper.

* Hook up highlighting to VSCode results.

Had to remove test for now.

* Fix lint.

* Split across multiple files.

* Changes for linting.

* Run lint tool.

* Potential fix for filtering issue.

* Add back pinned option.

* Removed extra info so tests pass again.

* Test with using scorer only.

If the score is 0, we can just exclude it, so seems pointless to do the regex and then that.
Will need to implement the filtering some other way though.

* Enable sorting with fuzzy finder.

* Added back fallback comparer.

* Fix lint.

* Make naming consistent.

* Bring in updated oni-api.

* Swap to a separate filter.

Bring back tests for RegEx filter.

* Fix bug with filtering.

* Bring over all the regex tests.

Converted to check highlights and score now too.

* Add score test.

* Added additional test.

* Added two tests for length.

* Remove replace and fallback.

Convert string was needed to deal with the regex, but since this is its own scorer it isn't needed.
Swapping to the default fallback fixes file length sorting when scores match.

* Tidy up files.

* Add test for search with file extension.

* Swap default.
  • Loading branch information
CrossR committed Apr 6, 2018
1 parent 3d21a97 commit afab2be
Show file tree
Hide file tree
Showing 14 changed files with 2,087 additions and 8 deletions.
2 changes: 1 addition & 1 deletion browser/src/Services/Configuration/DefaultConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const BaseConfiguration: IConfigurationValues = {
"editor.linePadding": 2,

"editor.quickOpen.execCommand": null,
"editor.quickOpen.filterStrategy": "regex",
"editor.quickOpen.filterStrategy": "vscode",

"editor.split.mode": "native",

Expand Down
17 changes: 13 additions & 4 deletions browser/src/Services/QuickOpen/QuickOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { render as renderPinnedIcon } from "./PinnedIconView"
import { QuickOpenItem, QuickOpenType } from "./QuickOpenItem"
import { regexFilter } from "./RegExFilter"
import * as RipGrep from "./RipGrep"
import { vsCodeFilter } from "./VSCodeFilter"

import { getFileIcon } from "./../FileIcon"

Expand Down Expand Up @@ -77,10 +78,18 @@ export class QuickOpen {

const filterStrategy = configuration.getValue("editor.quickOpen.filterStrategy")

const useRegExFilter = filterStrategy === "regex"

const filterFunction = useRegExFilter ? regexFilter : fuseFilter
this._menu.setFilterFunction(filterFunction)
switch (filterStrategy) {
case "fuse":
this._menu.setFilterFunction(fuseFilter)
break
case "regex":
this._menu.setFilterFunction(regexFilter)
break
case "vscode":
default:
this._menu.setFilterFunction(vsCodeFilter)
break
}

// If in exec directory or home, show bookmarks to change cwd to
if (this._isInstallDirectoryOrHome()) {
Expand Down
4 changes: 2 additions & 2 deletions browser/src/Services/QuickOpen/RegExFilter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* MenuFilter.ts
* RegExFilter.ts
*
* Implements filtering logic for the menu
* Implements RegEx filtering logic for the menu
*/

import * as sortBy from "lodash/sortBy"
Expand Down
Loading

0 comments on commit afab2be

Please sign in to comment.