@@ -295,7 +295,6 @@ setNonEnumerableReadOnly( SyntaxHighlighter.prototype, 'enable', function enable
295
295
* @returns {void }
296
296
*/
297
297
setNonEnumerableReadOnly ( SyntaxHighlighter . prototype , 'onKeypress' , function onKeypress ( ) {
298
- var highlightedLine ;
299
298
var tokens ;
300
299
301
300
if ( ! this . _enabled ) {
@@ -305,11 +304,8 @@ setNonEnumerableReadOnly( SyntaxHighlighter.prototype, 'onKeypress', function on
305
304
debug ( 'Empty line detected. Skipping highlighting...' ) ;
306
305
return ;
307
306
}
308
- // If no line change is detected, use the highlighted line from cache...
309
- if ( this . _line === this . _rli . line ) {
310
- debug ( 'No line change detected. Using cache...' ) ;
311
- highlightedLine = this . _highlightedLine ;
312
- } else {
307
+ // If line change is detected, tokenize & highlight the line. Use cache if no line change is detected...
308
+ if ( this . _line !== this . _rli . line ) {
313
309
// Update line buffer:
314
310
this . _line = this . _rli . line ;
315
311
@@ -322,16 +318,13 @@ setNonEnumerableReadOnly( SyntaxHighlighter.prototype, 'onKeypress', function on
322
318
}
323
319
// Highlight:
324
320
debug ( '%d tokens found. Highlighting...' , tokens . length ) ;
325
- highlightedLine = this . _highlightLine ( this . _line , tokens ) ;
326
-
327
- // Cache the newly highlighted line:
328
- this . _highlightedLine = highlightedLine ;
321
+ this . _highlightedLine = this . _highlightLine ( this . _line , tokens ) ;
329
322
}
330
323
// Replace:
331
324
debug ( 'Replacing current line with the highlighted line...' ) ;
332
325
readline . moveCursor ( this . _ostream , - 1 * this . _rli . cursor , 0 ) ;
333
326
readline . clearLine ( this . _ostream , 1 ) ;
334
- this . _ostream . write ( highlightedLine ) ;
327
+ this . _ostream . write ( this . _highlightedLine ) ;
335
328
readline . moveCursor ( this . _ostream , this . _rli . cursor - this . _line . length , 0 ) ; // eslint-disable-line max-len
336
329
} ) ;
337
330
0 commit comments