Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add fuzzy matching algorithm for tab completions #1855

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dc73372
feat: add fuzzy matching algorithm for tab completions
Snehil-Shah Mar 12, 2024
3cae6a7
refactor: fix function jsdoc
Snehil-Shah Mar 24, 2024
abe7525
Merge branch 'stdlib-js:develop' into repl-fuzzy
Snehil-Shah Mar 31, 2024
dcb6014
feat: rewrite the completer engine
Snehil-Shah Apr 2, 2024
bef5dd3
feat: improve fuzzy algorithm and sort by relevancy
Snehil-Shah Apr 2, 2024
0aee34d
feat: add support for highlighted completions in terminal mode
Snehil-Shah Apr 2, 2024
7efe1a7
fix: wrong completion previews displayed for fuzzy completion
Snehil-Shah Apr 2, 2024
b0ca5c1
fix: suggestions
Snehil-Shah Apr 3, 2024
7cc9270
feat: new tab completions UI with navigation
Snehil-Shah Apr 5, 2024
24da634
refactor: move `fuzzyMatch` to a module & don't fuzzy match for previews
Snehil-Shah Apr 5, 2024
6818055
fix: changes requested
Snehil-Shah Apr 5, 2024
95a72a4
Merge branch 'develop' into repl-fuzzy
Snehil-Shah Apr 5, 2024
0c8b11a
style: lint merged changes
Snehil-Shah Apr 5, 2024
6b7dc99
feat: add a setting to control fuzzy completions
Snehil-Shah Apr 5, 2024
237fb7f
fix: limit height of completions & fix completions with prefixes
Snehil-Shah Apr 5, 2024
576f402
feat: fuzzy completions only when no exact completions
Snehil-Shah Apr 6, 2024
89b5001
fix: bug in completer
Snehil-Shah Apr 6, 2024
c464944
test: add tests for tab completions
Snehil-Shah Apr 7, 2024
6d6d7c9
docs: fix test name and comments
Snehil-Shah Apr 8, 2024
2c15d15
fix: tune fuzzy algorithm
Snehil-Shah Apr 8, 2024
0e54cf5
docs: document setting
Snehil-Shah Apr 21, 2024
7128fac
Merge branch 'develop' into repl-fuzzy
Snehil-Shah Apr 25, 2024
fa22afb
fix: abnormal completer behavior
Snehil-Shah Apr 25, 2024
7b8074a
refactor: move flag to the completer engine namespace
Snehil-Shah Apr 25, 2024
cc2f3c5
refactor: abstract logics into private methods
Snehil-Shah Apr 26, 2024
85efce4
fix: make completer `SIGWINCH` aware
Snehil-Shah Apr 26, 2024
023c31a
test: update tests for TTY
Snehil-Shah Apr 26, 2024
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
Prev Previous commit
Next Next commit
fix: wrong completion previews displayed for fuzzy completion
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
  • Loading branch information
Snehil-Shah committed Apr 2, 2024
commit 7efe1a7e9bbfd84ca51694c4fd6220cd0f0d0ab4
6 changes: 6 additions & 0 deletions lib/node_modules/@stdlib/repl/lib/completer_preview.js
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ var readline = require( 'readline' );
var logger = require( 'debug' );
var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
var repeat = require( '@stdlib/string/repeat' );
var startsWith = require( '@stdlib/string/starts-with' );
var commonPrefix = require( './longest_common_prefix.js' );


@@ -114,6 +115,11 @@ setNonEnumerableReadOnly( PreviewCompleter.prototype, '_completionCallback', fun
debug( 'Unable to display a completion preview. Completion candidates have no common prefix.' );
return;
}
// If the input is not an exact prefix of the completion candidate's common prefix, no completion preview to display, as the common prefix is a fuzzy match (not exact) to the input string hence cannot contruct by simple concatenation...
if ( !startsWith( prefix, completions[1] ) ) {
debug( 'Unable to display a completion preview. Common prefix is a fuzzy match to the input' );
return;
}
// Extract the completion preview substring (e.g., if the current line is 'ba', preview should be 'ck'):
self._preview = prefix.substring( commonPrefix( prefix, completions[ 1 ] ).length ); // eslint-disable-line max-len

Loading
Oops, something went wrong.