File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -272,25 +272,21 @@ public void SetGrammar(IGrammar grammar)
272
272
{
273
273
if ( ! Object . Equals ( grammar , this . grammar ) )
274
274
{
275
+ Stop ( ) ;
276
+
275
277
this . grammar = grammar ;
276
278
this . tokenizer = new Tokenizer ( grammar ) ;
277
279
lines . ForEach ( ( line ) => line . ResetTokenizationState ( ) ) ;
278
280
lines . Get ( 0 ) . SetState ( tokenizer . GetInitialState ( ) ) ;
281
+
282
+ Start ( ) ;
279
283
InvalidateLine ( 0 ) ;
280
284
}
281
285
}
282
286
283
287
public void AddModelTokensChangedListener ( IModelTokensChangedListener listener )
284
288
{
285
- if ( this . fThread == null || this . fThread . IsStopped )
286
- {
287
- this . fThread = new TokenizerThread ( "TMModelThread" , this ) ;
288
- }
289
-
290
- if ( this . fThread . IsStopped )
291
- {
292
- this . fThread . Run ( ) ;
293
- }
289
+ Start ( ) ;
294
290
295
291
if ( ! listeners . Contains ( listener ) )
296
292
{
@@ -326,6 +322,19 @@ private void Stop()
326
322
this . fThread = null ;
327
323
}
328
324
325
+ private void Start ( )
326
+ {
327
+ if ( this . fThread == null || this . fThread . IsStopped )
328
+ {
329
+ this . fThread = new TokenizerThread ( "TMModelThread" , this ) ;
330
+ }
331
+
332
+ if ( this . fThread . IsStopped )
333
+ {
334
+ this . fThread . Run ( ) ;
335
+ }
336
+ }
337
+
329
338
private void BuildEventWithCallback ( Action < ModelTokensChangedEventBuilder > callback )
330
339
{
331
340
if ( this . fThread == null || this . fThread . IsStopped )
You can’t perform that action at this time.
0 commit comments