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
  • Loading branch information
cola119 committed Jun 23, 2022
1 parent f5ce6b1 commit 83c879a
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-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 83c879a

Please sign in to comment.