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 UX to cycle through completions in the REPL #2463

Merged
merged 27 commits into from
Jul 1, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
989e2b4
feat: add UX to cycle through completions
Snehil-Shah Jun 26, 2024
1d6ad40
Apply suggestions from code review
kgryte Jun 26, 2024
e8e0e9f
Apply suggestions from code review
Snehil-Shah Jun 27, 2024
535986f
fix: avoid navigating hidden completions
Snehil-Shah Jun 28, 2024
4babb98
refactor: use `\n` instead of `\r\n`
Snehil-Shah Jun 28, 2024
755ddee
fix: abnormal behavior with ENTER
Snehil-Shah Jun 28, 2024
2fcb356
fix: duplicate line events
Snehil-Shah Jun 28, 2024
9de549d
fix: incorrect height
Snehil-Shah Jun 28, 2024
2b1f666
fix: bug with ENTER
Snehil-Shah Jun 28, 2024
7510ba9
test: add test case
Snehil-Shah Jun 28, 2024
da8f7ee
test: fix brittle test cases
Snehil-Shah Jun 28, 2024
63ce461
feat: allow sustaining the completions panel
Snehil-Shah Jun 29, 2024
d4afb81
fix: reorder keypress handlers according to precedence
Snehil-Shah Jun 29, 2024
858eddb
fix: make it receptive to SIGINT events
Snehil-Shah Jun 29, 2024
6fd48a8
fix: reorder keypress handlers according to precedence
Snehil-Shah Jun 29, 2024
5bb319c
feat: allow navigating the line when navigating
Snehil-Shah Jun 29, 2024
7f4eac7
refactor: clean logic and avoid unnecessary re-rendering
Snehil-Shah Jun 29, 2024
ddcd3d6
test: remove outdated test
Snehil-Shah Jun 29, 2024
494f845
fix: don't close when completer is already closed
Snehil-Shah Jun 29, 2024
141bfe4
test: add test case for live completions
Snehil-Shah Jun 30, 2024
5410b2b
fix: incorrect logic
Snehil-Shah Jul 1, 2024
3677b2a
fix: incorrect keypress handlers
Snehil-Shah Jul 1, 2024
e53f691
test: update test names
Snehil-Shah Jul 1, 2024
4b8a752
docs: fix jsdoc
Snehil-Shah Jul 1, 2024
71b5c4c
fix: update after inserting a completion
Snehil-Shah Jul 1, 2024
e862980
Apply suggestions from code review
kgryte Jul 1, 2024
97329bf
Apply suggestions from code review
kgryte Jul 1, 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 test case
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
  • Loading branch information
Snehil-Shah committed Jun 28, 2024
commit 7510ba9feca397edbe7b3993b68bdcb41ab4f2e4
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ tape( 'a REPL instance supports hiding the completions panel upon pressing TAB a
t.fail( error.message );
return;
}

// Check if the completions were cleared:
t.strictEqual( data[ data.length - 2 ], '\x1B[0J', 'returns expected value' );

Expand All @@ -204,6 +203,58 @@ tape( 'a REPL instance supports hiding the completions panel upon pressing TAB a
}
});

tape( 'a REPL instance supports hiding the completions panel upon typing again', function test( t ) {
var istream;
var opts;
var r;

istream = new DebugStream({
'name': 'repl-input-stream'
});
opts = {
'input': istream,
'settings': defaultSettings(),
'tty': {
'rows': 100,
'columns': 80
}
};
r = repl( opts, onClose );

// Declare variables with unique names in order to prevent namespace collisions:
istream.write( 'var zzzxy = 1;' );
istream.write( 'var zzzab = 2;' );

// Write the common substring of the variable names in order to generate completions:
istream.write( 'zzz' );

// Write TAB to display completions:
istream.write( '\t' );

// Write TAB again to hide completions:
istream.write( 'a' );

// Close the input stream:
istream.end();

// Close the REPL:
r.close();

function onClose( error, data ) {
if ( error ) {
t.fail( error.message );
return;
}
// Check if the completions were cleared:
t.strictEqual( data[ data.length - 3 ], '\x1B[0J', 'returns expected value' );
t.strictEqual( data[ data.length - 1 ], 'a', 'returns expected value' );

// NOTE: `data[ data.length-2 ]` adds the remaining string to the right of the cursor because of the abnormal behaviour of `clearScreenDown`...

t.end();
}
});

tape( 'a REPL instance supports navigating the TAB completions using arrow keys', function test( t ) {
var istream;
var opts;
Expand Down
Loading