Skip to content

Commit c00dcc0

Browse files
committed
fix(mobile): keep a definition's memo past mid-line candidates
Definition-shaped text after code in a title isn't a definition, but it overwrote the memo for its line, so the next definition looked lazy. Signed-off-by: Tom Brow <[email protected]>
1 parent 2695de2 commit c00dcc0

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎mobile/lib/features/channels/message_content/link_normalizer.dart‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ class _DefinitionScan {
6565
}
6666

6767
bool _counts(int index) {
68+
// A candidate mid-line, after code, is not a definition and leaves the
69+
// memo for the line it sits on alone.
70+
if (index > 0 && content[index - 1] != '\n') return false;
6871
final bool counted;
69-
if (index > 0 && content[index - 1] != '\n') {
70-
counted = false;
71-
} else if (index == _lastEnd + 1) {
72+
if (index == _lastEnd + 1) {
7273
counted = _lastCounted;
7374
} else {
7475
final previousEnd = index - 1;

‎mobile/test/features/channels/message_content/link_normalizer_test.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ void main() {
3232
'[a]: $site "`code`"\n[b]: $site\n\n[b]',
3333
'[a]: $site "`code`"\n[b]: $site\n\n[b]',
3434
),
35+
(
36+
'[a]: $site "`code` [fake]: x"\n[b]: $site\n\n[b]',
37+
'[a]: $site "`code` [fake]: x"\n[b]: $site\n\n[b]',
38+
),
3539
(
3640
'text\n[a]: $site\n[b]: $site',
3741
'text\n[a]: [$site]($site)\n[b]: [$site]($site)',

0 commit comments

Comments
 (0)