Skip to content

Commit

Permalink
readline: fix to not access a property on an undefined value
Browse files Browse the repository at this point in the history
PR-URL: #43543
Reviewed-By: Antoine du Hamel <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Yongsheng Zhang <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
cola119 authored and targos committed Jul 31, 2022
1 parent a5089c9 commit 67e91aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/internal/readline/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ function* emitKeys(stream) {

// This runs in O(n log n).
function commonPrefix(strings) {
if (strings.length === 0) {
return '';
}
if (strings.length === 1) {
return strings[0];
}
Expand Down
21 changes: 21 additions & 0 deletions test/parallel/test-repl-tab-complete-on-editor-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

require('../common');
const ArrayStream = require('../common/arraystream');
const repl = require('repl');

const stream = new ArrayStream();
const replServer = repl.start({
input: stream,
output: stream,
terminal: true,
});

// Editor mode
replServer.write('.editor\n');

// Regression test for https://github.com/nodejs/node/issues/43528
replServer.write('a');
replServer.write(null, { name: 'tab' }); // Should not throw

replServer.close();

0 comments on commit 67e91aa

Please sign in to comment.