1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-10 18:10:44 +09:00

Editor | Fix | Numbered block pattern triggered when not needed due to an incorrect regex pattern (#1987)

This commit is contained in:
Evgenii Kozlov 2021-12-01 22:36:22 +03:00 committed by GitHub
parent 2a1fbce079
commit 84ba4ab8fd
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 1 deletions

View file

@ -6,6 +6,10 @@
* App | Reminding our users about saving the mnemonic phrase (#1982)
### Fixes & tech 🚒
Editor | Fix | Numbered block pattern triggered when not needed due to an incorrect regex pattern (#1987)
## Version 0.4.4
### Design & UX 🔳

View file

@ -22,4 +22,33 @@ class DefaultPatternMatcherTest {
)
}
}
@Test
fun `should detect numbered pattern`() {
val strings = listOf("1. ")
strings.forEach { text ->
val result = matcher.match(text)
assertEquals(
expected = listOf(Pattern.NUMBERED),
actual = result
)
}
}
@Test
fun `should not detect numbered pattern`() {
val strings = listOf("1", "1.", "1 .", "1,", "1, ","1* ","1# ")
strings.forEach { text ->
val result = matcher.match(text)
print("matching: $text")
assertEquals(
expected = emptyList(),
actual = result
)
}
}
}

View file

@ -32,7 +32,7 @@ class DefaultPatternMatcher : Matcher<Pattern> {
}
companion object {
const val REGEX_NUMBERED_LIST_PATTERN = "^1. "
const val REGEX_NUMBERED_LIST_PATTERN = "^1\\. "
const val REGEX_DIVIDER_PATTERN = "^---"
const val REGEX_CHECKBOX_PATTERN = "^\\[]"
const val REGEX_HEADER_ONE_PATERN = "^# "