From e196c5c0a15c9fdb1ff2610b1e9c941583864cf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Szabo?= Date: Sun, 23 Oct 2022 12:29:31 -0300 Subject: [PATCH 1/2] Adding Zadeh --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2fb9618..f11a8cc 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "fs-plus": "^3.0.0", "fuzzaldrin": "^2.0", "fuzzaldrin-plus": "^0.6.0", - "@atom/fuzzy-native": "^1.1.2", + "zadeh": "3.0.0-beta.4", "humanize-plus": "~1.8.2", "minimatch": "~3.0.3", "temp": "~0.8.1", From 1e0df0ba367ef04014e215661f9a85279bdf3539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Szabo?= Date: Sun, 23 Oct 2022 12:37:24 -0300 Subject: [PATCH 2/2] Use only ONE scoring system --- lib/fuzzy-finder-view.js | 78 +++------------------------------------- package.json | 2 -- 2 files changed, 5 insertions(+), 75 deletions(-) diff --git a/lib/fuzzy-finder-view.js b/lib/fuzzy-finder-view.js index 7fde77e..b500e7e 100644 --- a/lib/fuzzy-finder-view.js +++ b/lib/fuzzy-finder-view.js @@ -1,9 +1,7 @@ const {Point, CompositeDisposable} = require('atom') const {renderExperimentPrompt, shouldShowPrompt} = require('./experiment-prompt') const fs = require('fs-plus') -const fuzzaldrin = require('fuzzaldrin') const fuzzaldrinPlus = require('fuzzaldrin-plus') -const NativeFuzzy = require('@atom/fuzzy-native') const SCORING_SYSTEMS = require('./scoring-systems') const path = require('path') @@ -85,25 +83,7 @@ module.exports = class FuzzyFinderView { elementForItem: ({filePath, label, ownerGitHubUsername}) => { const filterQuery = this.selectListView.getFilterQuery() - let matches - - switch (this.scoringSystem) { - case SCORING_SYSTEMS.STANDARD: - matches = fuzzaldrin.match(label, filterQuery) - break - case SCORING_SYSTEMS.FAST: - this.nativeFuzzyForResults.setCandidates([0], [label]) - const items = this.nativeFuzzyForResults.match( - filterQuery, - {maxResults: 1, recordMatchIndexes: true} - ) - matches = items.length ? items[0].matchIndexes : [] - break - default: - matches = fuzzaldrinPlus.match(label, filterQuery) - break - } - + let matches = fuzzaldrinPlus.match(label, filterQuery) const repository = repositoryForPath(filePath) return new FuzzyFinderItem({ @@ -143,34 +123,8 @@ module.exports = class FuzzyFinderView { } }) - this.subscriptions = new CompositeDisposable() - this.subscriptions.add( - atom.config.observe('fuzzy-finder.scoringSystem', (newValue) => { - this.scoringSystem = newValue - - if (this.scoringSystem === SCORING_SYSTEMS.STANDARD) { - this.selectListView.update({filter: null}) - } else if (this.scoringSystem === SCORING_SYSTEMS.FAST) { - if (!this.nativeFuzzy) { - this.nativeFuzzy = new NativeFuzzy.Matcher( - indexArray(this.items.length), - this.items.map(el => el.label) - ) - - // We need a separate instance of the fuzzy finder to calculate the - // matched paths only for the returned results. This speeds up considerably - // the filtering of items. - this.nativeFuzzyForResults = new NativeFuzzy.Matcher([], []) - } - - this.selectListView.update({ filter: this.filterFn }) - } else { - this.selectListView.update({ filter: this.filterFn }) - } - - this.updateExperimentPrompt() - }) - ) + this.selectListView.update({ filter: this.filterFn }) + this.updateExperimentPrompt() } get element () { @@ -182,11 +136,6 @@ module.exports = class FuzzyFinderView { this.panel.destroy() } - if (this.subscriptions) { - this.subscriptions.dispose() - this.subscriptions = null - } - return this.selectListView.destroy() } @@ -332,14 +281,6 @@ module.exports = class FuzzyFinderView { setItems (items) { this.items = items - if (this.scoringSystem === SCORING_SYSTEMS.FAST) { - // Beware: this operation is quite slow for large projects! - this.nativeFuzzy.setCandidates( - indexArray(this.items.length), - this.items.map(item => item.label) - ) - } - if (this.isQueryALineJump()) { this.selectListView.update({ items: [], @@ -403,19 +344,10 @@ module.exports = class FuzzyFinderView { return items } - let results const startTime = performance.now() - - if (this.scoringSystem === SCORING_SYSTEMS.FAST) { - results = this.nativeFuzzy.match(query, {maxResults: MAX_RESULTS}) - .map(({id}) => this.items[id]) - } else { - results = fuzzaldrinPlus.filter(items, query, {key: 'label'}) - } - + let results = fuzzaldrinPlus.filter(items, query, {key: 'label'}) const duration = Math.round(performance.now() - startTime) - - this.metricsReporter.sendFilterEvent(duration, items.length, this.scoringSystem) + this.metricsReporter.sendFilterEvent(duration, items.length, 'fuzzaldrin-plus') return results } diff --git a/package.json b/package.json index f11a8cc..407531c 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,7 @@ "async": "0.2.6", "atom-select-list": "^0.7.0", "fs-plus": "^3.0.0", - "fuzzaldrin": "^2.0", "fuzzaldrin-plus": "^0.6.0", - "zadeh": "3.0.0-beta.4", "humanize-plus": "~1.8.2", "minimatch": "~3.0.3", "temp": "~0.8.1",