@@ -10,7 +10,7 @@ import { disposeOnigString, IOnigLib, OnigScanner, OnigString } from '../onigLib
1010import { IRawGrammar , IRawRepository , IRawRule } from '../rawGrammar' ;
1111import { ruleIdFromNumber , IRuleFactoryHelper , IRuleRegistry , Rule , RuleFactory , RuleId , ruleIdToNumber } from '../rule' ;
1212import { FontStyle , ScopeName , ScopePath , ScopeStack , StyleAttributes } from '../theme' ;
13- import { clone } from '../utils' ;
13+ import { clone , containsRTL } from '../utils' ;
1414import { BasicScopeAttributes , BasicScopeAttributesProvider } from './basicScopesAttributeProvider' ;
1515import { _tokenizeString } from './tokenizeString' ;
1616
@@ -960,6 +960,7 @@ export class LineTokens {
960960 private _lastTokenEndIndex : number ;
961961
962962 private readonly _tokenTypeOverrides : TokenTypeMatcher [ ] ;
963+ private readonly _mergeConsecutiveTokensWithEqualMetadata : boolean ;
963964
964965 constructor (
965966 emitBinaryTokens : boolean ,
@@ -974,6 +975,8 @@ export class LineTokens {
974975 } else {
975976 this . _lineText = null ;
976977 }
978+ // Don't merge tokens if the line contains RTL characters
979+ this . _mergeConsecutiveTokensWithEqualMetadata = ! containsRTL ( lineText ) ;
977980 this . _tokens = [ ] ;
978981 this . _binaryTokens = [ ] ;
979982 this . _lastTokenEndIndex = 0 ;
@@ -1031,7 +1034,7 @@ export class LineTokens {
10311034 ) ;
10321035 }
10331036
1034- if ( this . _binaryTokens . length > 0 && this . _binaryTokens [ this . _binaryTokens . length - 1 ] === metadata ) {
1037+ if ( this . _mergeConsecutiveTokensWithEqualMetadata && this . _binaryTokens . length > 0 && this . _binaryTokens [ this . _binaryTokens . length - 1 ] === metadata ) {
10351038 // no need to push a token with the same metadata
10361039 this . _lastTokenEndIndex = endIndex ;
10371040 return ;
0 commit comments