Diff of /lexers/LexCoffeeScript.cxx [67d7ef] .. [dd2348]  Maximize  Restore

Switch to unified view

a/lexers/LexCoffeeScript.cxx b/lexers/LexCoffeeScript.cxx
...
...
135
        }
135
        }
136
    }
136
    }
137
137
138
    // look back to set chPrevNonWhite properly for better regex colouring
138
    // look back to set chPrevNonWhite properly for better regex colouring
139
    int endPos = startPos + length;
139
    int endPos = startPos + length;
140
  if (startPos > 0) {
140
        if (startPos > 0 && IsSpaceEquiv(initStyle)) {
141
        unsigned int back = startPos;
141
        unsigned int back = startPos;
142
        styler.Flush();
142
        styler.Flush();
143
        while (back > 0 && IsSpaceEquiv(styler.StyleAt(--back)))
143
        while (back > 0 && IsSpaceEquiv(styler.StyleAt(--back)))
144
            ;
144
            ;
145
        if (styler.StyleAt(back) == SCE_C_OPERATOR) {
145
        if (styler.StyleAt(back) == SCE_C_OPERATOR) {
146
            chPrevNonWhite = styler.SafeGetCharAt(back);
146
            chPrevNonWhite = styler.SafeGetCharAt(back);
147
        }
147
        }
148
        if (startPos != back) {
148
        if (startPos != back) {
149
            initStyle = styler.StyleAt(back);
149
            initStyle = styler.StyleAt(back);
150
          if (IsSpaceEquiv(initStyle)) {
151
              initStyle = SCE_C_DEFAULT;
152
          }
150
        }
153
        }
151
        startPos = back;
154
        startPos = back;
152
    }
155
    }
153
156
154
    StyleContext sc(startPos, endPos - startPos, initStyle, styler);
157
    StyleContext sc(startPos, endPos - startPos, initStyle, styler);
...
...
319
                    sc.SetState(SCE_C_DEFAULT);
322
                    sc.SetState(SCE_C_DEFAULT);
320
                }
323
                }
321
                break;
324
                break;
322
            case SCE_COFFEESCRIPT_COMMENTBLOCK:
325
            case SCE_COFFEESCRIPT_COMMENTBLOCK:
323
                if (sc.Match("###")) {
326
                if (sc.Match("###")) {
324
                  sc.ChangeState(SCE_C_COMMENT);
325
                    sc.Forward();
327
                    sc.Forward();
326
                    sc.Forward();
328
                    sc.Forward();
327
                    sc.ForwardSetState(SCE_C_DEFAULT);
329
                    sc.ForwardSetState(SCE_C_DEFAULT);
328
                } else if (sc.ch == '\\') {
330
                } else if (sc.ch == '\\') {
329
                    sc.Forward();
331
                    sc.Forward();
...
...
331
                break;
333
                break;
332
            case SCE_COFFEESCRIPT_VERBOSE_REGEX:
334
            case SCE_COFFEESCRIPT_VERBOSE_REGEX:
333
                if (sc.Match("///")) {
335
                if (sc.Match("///")) {
334
                    sc.Forward();
336
                    sc.Forward();
335
                    sc.Forward();
337
                    sc.Forward();
336
                  sc.ChangeState(SCE_C_REGEX);
337
                    sc.ForwardSetState(SCE_C_DEFAULT);
338
                    sc.ForwardSetState(SCE_C_DEFAULT);
338
                } else if (sc.Match('#')) {
339
                } else if (sc.Match('#')) {
339
                  sc.ChangeState(SCE_C_REGEX);
340
                    sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT);
340
                    sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT);
341
                } else if (sc.ch == '\\') {
341
                } else if (sc.ch == '\\') {
342
                    sc.Forward();
342
                    sc.Forward();
343
                }
343
                }
344
                break;
344
                break;
345
            case SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT:
345
            case SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT:
346
                if (sc.atLineStart) {
346
                if (sc.atLineStart) {
347
                  sc.ChangeState(SCE_C_COMMENT);
348
                    sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX);
347
                    sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX);
349
                }
348
                }
350
                break;
349
                break;
351
        }
350
        }
352
351
...
...
376
                    sc.SetState(SCE_C_COMMENT);
375
                    sc.SetState(SCE_C_COMMENT);
377
                }
376
                }
378
                sc.Forward();   // Eat the * so it isn't used for the end of the comment
377
                sc.Forward();   // Eat the * so it isn't used for the end of the comment
379
            } else if (sc.Match("///")) {
378
            } else if (sc.Match("///")) {
380
                sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX);
379
                sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX);
380
              sc.Forward();
381
              sc.Forward();
381
            } else if (sc.ch == '/'
382
            } else if (sc.ch == '/'
382
                   && (setOKBeforeRE.Contains(chPrevNonWhite)
383
                   && (setOKBeforeRE.Contains(chPrevNonWhite)
383
                       || followsReturnKeyword(sc, styler))
384
                       || followsReturnKeyword(sc, styler))
384
                   && (!setCouldBePostOp.Contains(chPrevNonWhite)
385
                   && (!setCouldBePostOp.Contains(chPrevNonWhite)
385
                       || !FollowsPostfixOperator(sc, styler))) {
386
                       || !FollowsPostfixOperator(sc, styler))) {
...
...
390
            } else if (isIncludePreprocessor && sc.ch == '<') {
391
            } else if (isIncludePreprocessor && sc.ch == '<') {
391
                sc.SetState(SCE_C_STRING);
392
                sc.SetState(SCE_C_STRING);
392
            } else if (sc.ch == '\'') {
393
            } else if (sc.ch == '\'') {
393
                sc.SetState(SCE_C_CHARACTER);
394
                sc.SetState(SCE_C_CHARACTER);
394
            } else if (sc.ch == '#') {
395
            } else if (sc.ch == '#') {
395
                if (sc.Match("###")) {
396
              if (sc.Match("###")) {
396
                    sc.SetState(SCE_COFFEESCRIPT_COMMENTBLOCK);
397
                  sc.SetState(SCE_COFFEESCRIPT_COMMENTBLOCK);
397
                } else {
398
                  sc.Forward();
398
                    sc.SetState(SCE_C_COMMENTLINE);
399
                  sc.Forward();
399
                }
400
                  
401
              } else {
402
                  sc.SetState(SCE_C_COMMENTLINE);
403
              }
400
            } else if (isoperator(static_cast<char>(sc.ch))) {
404
            } else if (isoperator(static_cast<char>(sc.ch))) {
401
                sc.SetState(SCE_C_OPERATOR);
405
                sc.SetState(SCE_C_OPERATOR);
402
            }
406
            }
403
        }
407
        }
404
408
...
...
406
            chPrevNonWhite = sc.ch;
410
            chPrevNonWhite = sc.ch;
407
            visibleChars++;
411
            visibleChars++;
408
        }
412
        }
409
        continuationLine = false;
413
        continuationLine = false;
410
    }
414
    }
411
    // Change temporary coffeescript states into standard C ones.
412
    switch (sc.state) {
413
        case SCE_COFFEESCRIPT_COMMENTBLOCK:
414
            sc.ChangeState(SCE_C_COMMENT);
415
            break;
416
        case SCE_COFFEESCRIPT_VERBOSE_REGEX:
417
            sc.ChangeState(SCE_C_REGEX);
418
            break;
419
        case SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT:
420
            sc.ChangeState(SCE_C_COMMENTLINE);
421
            break;
422
    }
423
    sc.Complete();
415
    sc.Complete();
424
}
416
}
425
417
426
static bool IsCommentLine(int line, Accessor &styler) {
418
static bool IsCommentLine(int line, Accessor &styler) {
427
    int pos = styler.LineStart(line);
419
    int pos = styler.LineStart(line);