File src/Highlighter.cpp changed (mode: 100644) (index 4b78fad..5a26594) |
... |
... |
toWords(boost::string_ref s) |
613 |
613 |
return Word; |
return Word; |
614 |
614 |
}; |
}; |
615 |
615 |
|
|
|
616 |
|
auto isNonWord = [](State state) { |
|
617 |
|
return (state == Punctuation || state == WhiteSpace); |
|
618 |
|
}; |
|
619 |
|
|
|
620 |
|
auto hasInput = [](State state) { |
|
621 |
|
return (state != Start && state != End); |
|
622 |
|
}; |
|
623 |
|
|
616 |
624 |
State currentState = Start; |
State currentState = Start; |
617 |
625 |
std::size_t wordStart = 0U; |
std::size_t wordStart = 0U; |
618 |
626 |
for (std::size_t i = 0U; i <= s.size(); ++i) { |
for (std::size_t i = 0U; i <= s.size(); ++i) { |
619 |
627 |
const State newState = (i == s.size() ? End : classify(s[i])); |
const State newState = (i == s.size() ? End : classify(s[i])); |
620 |
|
// Each punctuation character is treated as a separate "word". |
|
621 |
|
if (currentState != newState || currentState == Punctuation) { |
|
622 |
|
if (currentState == Punctuation || currentState == Word) { |
|
|
628 |
|
// Each punctuation or whitespace character is treated as a separate |
|
629 |
|
// "word". |
|
630 |
|
if (currentState != newState || isNonWord(currentState)) { |
|
631 |
|
if (hasInput(currentState)) { |
623 |
632 |
words.emplace_back(s.substr(wordStart, i - wordStart)); |
words.emplace_back(s.substr(wordStart, i - wordStart)); |
624 |
633 |
} |
} |
625 |
|
if (newState == Punctuation || newState == Word) { |
|
|
634 |
|
if (hasInput(newState)) { |
626 |
635 |
wordStart = i; |
wordStart = i; |
627 |
636 |
} |
} |
628 |
637 |
} |
} |
File tests/Printer.cpp changed (mode: 100644) (index d0b5c24..dd8a2ea) |
... |
... |
TEST_CASE("Separators in diffable tokens are handled separately", "[printer]") |
534 |
534 |
)"), true); |
)"), true); |
535 |
535 |
|
|
536 |
536 |
std::string expected = normalizeText(R"( |
std::string expected = normalizeText(R"( |
537 |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
538 |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
|
537 |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
538 |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
539 |
539 |
1 | 1 |
1 | 1 |
540 |
540 |
2 void f() { | 2 void f() { |
2 void f() { | 2 void f() { |
541 |
|
3 something("Destination doesn't exist"); {#~#} 3 something("Destination doesn't exist {+or+} {+not+} {+a+} {+directory+}"); |
|
|
541 |
|
3 something("Destination doesn't exist"); {#~#} 3 something("Destination doesn't exist{+ or not a directory+}"); |
542 |
542 |
4 } | 4 } |
4 } | 4 } |
543 |
543 |
)"); |
)"); |
544 |
544 |
|
|
File tests/alignment.cpp changed (mode: 100644) (index dd289ec..569ef93) |
... |
... |
TEST_CASE("Lines with matching nodes are aligned for multiline tokens", |
236 |
236 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
237 |
237 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
238 |
238 |
1 | 1 |
1 | 1 |
239 |
|
2 /* This is an example {-file-}. */ {#~#} 2 /* This {+file+} is an example {+used+} |
|
240 |
|
- {+++} 3 {+*+} {+to+} {+compare+} {+diffs+}. */ |
|
|
239 |
|
2 /* This is an example {-file-}. */ {#~#} 2 /* This {+file +}is an example {+used+} |
|
240 |
|
- {+++} 3 {+ * to compare diffs+}. */ |
241 |
241 |
3 int check({-int-}{- -}{-id-}, const char {~inf~}[]) { {#~#} 4 int check({+pid_t+}{+ +}{+pid+}, const char {~inf~}{+o+}[]{+,+}{+ +}{+time_t+}{+ +}{+start+}) { |
3 int check({-int-}{- -}{-id-}, const char {~inf~}[]) { {#~#} 4 int check({+pid_t+}{+ +}{+pid+}, const char {~inf~}{+o+}[]{+,+}{+ +}{+time_t+}{+ +}{+start+}) { |
242 |
242 |
4 int status; {#~#} 5 int status {+=+}{+ +}{+0+}; |
4 int status; {#~#} 5 int status {+=+}{+ +}{+0+}; |
243 |
243 |
- {+++} 6 {+if+}{+ +}{+(+}{+start+}{+ +}{+!=+}{+ +}{+(+}{+time_t+}{+)+}{+-+}{+1+}{+)+}{+ +}{+{+} |
- {+++} 6 {+if+}{+ +}{+(+}{+start+}{+ +}{+!=+}{+ +}{+(+}{+time_t+}{+)+}{+-+}{+1+}{+)+}{+ +}{+{+} |
File tests/c/c-printing.cpp changed (mode: 100644) (index de3f2d6..f478e7f) |
... |
... |
TEST_CASE("Directives are diffed", "[printer]") |
30 |
30 |
); |
); |
31 |
31 |
|
|
32 |
32 |
std::string expected = normalizeText(R"( |
std::string expected = normalizeText(R"( |
33 |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
34 |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
35 |
|
1 #define DEFINE (1 + 2 + 3) {#~#} 1 #define DEFINE (1 + 2 + 3 {+++} {+4+}) |
|
|
33 |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
34 |
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
35 |
|
1 #define DEFINE (1 + 2 + 3) {#~#} 1 #define DEFINE (1 + 2 + 3{+ + 4+}) |
36 |
36 |
)"); |
)"); |
37 |
37 |
|
|
38 |
38 |
REQUIRE(printed == expected); |
REQUIRE(printed == expected); |