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
test: add tests for tab completions
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
  • Loading branch information
Snehil-Shah committed Apr 7, 2024
commit c4649445ef6767805f6a8c3eedbd30d879f3769f
26 changes: 20 additions & 6 deletions lib/node_modules/@stdlib/repl/lib/completer_engine.js
Original file line number Diff line number Diff line change
@@ -188,7 +188,7 @@ setNonEnumerableReadOnly( CompleterEngine.prototype, '_completionCallback', func
// Move the cursor to the start of completion prefix:
self._rli.cursor -= self._completionPrefix.length;

// Write the auto-completion string
// Write the auto-completion string:
self._rli.write( autoCompletion );

// Resume the input stream:
@@ -368,6 +368,7 @@ setNonEnumerableReadOnly( CompleterEngine.prototype, '_navigateCompletions', fun
output += repeat( ' ', whitespaces );
}
if ( i === this._output.index && this.repl._isTTY ) {
// Highlight the current navigated index:
completion = stripANSI( completion );
completion = '\u001b[7m' + completion + '\u001b[27m';
}
@@ -440,7 +441,6 @@ setNonEnumerableReadOnly( CompleterEngine.prototype, 'beforeKeypress', function
// Move to the previous row or if already on the line, stop navigating and trigger default behaviour...
if ( this._output.index === -1 ) {
readline.clearScreenDown( this._ostream );
this._output.index = -1;
this.repl._isNavigatingCompletions = false;
this._ttyWrite.call( this._rli, data, key );
return;
@@ -452,17 +452,31 @@ setNonEnumerableReadOnly( CompleterEngine.prototype, 'beforeKeypress', function
}
this._navigateCompletions();
} else if ( key.name === 'left' ) {
// Move back an index...
// If on current line, trigger default behaviour and stop navigating...
if ( this._output.index === -1 ) {
readline.clearScreenDown( this._ostream );
this.repl._isNavigatingCompletions = false;
this._ttyWrite.call( this._rli, data, key );
return;
}
// If navigating, move back an index...
if ( this._output.index > 0 ) {
this._output.index -= 1;
this._navigateCompletions();
}
this._navigateCompletions();
} else if ( key.name === 'right' ) {
// Move ahead an index...
// If on current line, trigger default behaviour and stop navigating...
if ( this._output.index === -1 ) {
readline.clearScreenDown( this._ostream );
this.repl._isNavigatingCompletions = false;
this._ttyWrite.call( this._rli, data, key );
return;
}
// If navigating, move ahead an index...
if ( this._output.index < this._completionsList.length - 1 ) {
this._output.index += 1;
this._navigateCompletions();
}
this._navigateCompletions();
} else {
// For any other keypress, stop navigating and continue default behaviour...
readline.clearScreenDown( this._ostream );
Loading
Oops, something went wrong.
Loading
Oops, something went wrong.