Skip to content

Commit 27aaf8f

Browse files
committed
refactor: move processLine inside multilineHandler class
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
1 parent 9c3bb24 commit 27aaf8f

File tree

4 files changed

+270
-273
lines changed

4 files changed

+270
-273
lines changed

lib/node_modules/@stdlib/repl/lib/main.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ var commands = require( './commands.js' );
6161
var displayPrompt = require( './display_prompt.js' );
6262
var inputPrompt = require( './input_prompt.js' );
6363
var OutputStream = require( './output_stream.js' );
64-
var processLine = require( './process_line.js' );
6564
var completerFactory = require( './completer.js' );
6665
var MultilineHandler = require( './multiline_handler.js' );
6766
var PreviewCompleter = require( './completer_preview.js' );
@@ -238,14 +237,6 @@ function REPL( options ) {
238237
// Define the current workspace:
239238
setNonEnumerable( this, '_currentWorkspace', 'base' );
240239

241-
// Initialize an internal status object for multi-line mode:
242-
setNonEnumerable( this, '_multiline', {} );
243-
setNonEnumerable( this._multiline, 'active', false );
244-
setNonEnumerable( this._multiline, 'mode', 'incomplete_expression' );
245-
setNonEnumerable( this._multiline, 'line', 0 );
246-
setNonEnumerable( this._multiline, 'lines', [] );
247-
setNonEnumerable( this._multiline, 'buffer', '' );
248-
249240
// Initialize an internal flag indicating whether the REPL has been closed:
250241
setNonEnumerable( this, '_closed', false );
251242

@@ -354,7 +345,7 @@ function REPL( options ) {
354345
completed = self._previewCompleter.beforeKeypress( data, key );
355346

356347
// If completion was auto-completed, don't trigger multiline keybindings to avoid double operations...
357-
if ( !completed && self._multiline.active ) {
348+
if ( !completed ) {
358349
self._multilineHandler.beforeKeypress( data, key );
359350
return;
360351
}
@@ -395,7 +386,7 @@ function REPL( options ) {
395386
function onLine( line ) {
396387
self._SIGINT = false; // reset flag
397388
if ( self._closed === false ) {
398-
processLine( self, line );
389+
self._multilineHandler.processLine( line );
399390
}
400391
}
401392

@@ -524,19 +515,6 @@ setNonEnumerableReadOnly( REPL.prototype, '_prompt', function prompt() {
524515
return inputPrompt( this._inputPrompt, this._count );
525516
});
526517

527-
/**
528-
* Returns the height of the current input.
529-
*
530-
* @private
531-
* @name _inputHeight
532-
* @memberof REPL.prototype
533-
* @type {Function}
534-
* @returns {number} input rows
535-
*/
536-
setNonEnumerableReadOnly( REPL.prototype, '_inputHeight', function inputHeight() {
537-
return this._multiline.lines.length;
538-
});
539-
540518
/**
541519
* Returns the REPL viewport.
542520
*

0 commit comments

Comments
 (0)