Skip to content
This repository was archived by the owner on Sep 17, 2025. It is now read-only.

Commit 73edd5f

Browse files
committed
Update 1.5.9
1 parent 5f372f7 commit 73edd5f

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

app/src/main/java/com/yangdai/opennote/presentation/component/note/LiteTextField.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ fun LiteTextField(
274274

275275
if (selection.start == currentLineEnd &&
276276
(trimmedLine == "- [ ]" || trimmedLine == "-" || trimmedLine == "*" || trimmedLine == "+"
277-
|| trimmedLine.matches(Regex("^\\d+\\.$")))
277+
|| trimmedLine.matches(Regex("^\\d+\\.$")) || trimmedLine.matches(Regex("^\\d+\\)$")))
278278
) {
279279
val newText = StringBuilder(currentText)
280280
.delete(currentLineStart, currentLineEnd)
@@ -297,7 +297,12 @@ fun LiteTextField(
297297
?.plus(1) ?: 1
298298
"$nextNumber. "
299299
}
300-
300+
trimmedLine.matches(Regex("^\\d+\\)\\s.*")) -> {
301+
val nextNumber =
302+
trimmedLine.substringBefore(")").toIntOrNull()
303+
?.plus(1) ?: 1
304+
"$nextNumber) "
305+
}
301306
trimmedLine.startsWith("- ") -> "- "
302307
trimmedLine.startsWith("* ") -> "* "
303308
trimmedLine.startsWith("+ ") -> "+ "

app/src/main/java/com/yangdai/opennote/presentation/component/note/StandardTextField.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ fun StandardTextField(
388388
// 处理空列表项
389389
if (selection.start == currentLineEnd &&
390390
(trimmedLine == "- [ ]" || trimmedLine == "-" || trimmedLine == "*" || trimmedLine == "+"
391-
|| trimmedLine.matches(Regex("^\\d+\\.$")))
391+
|| trimmedLine.matches(Regex("^\\d+\\.$")) || trimmedLine.matches(Regex("^\\d+\\)$")))
392392
) {
393393
state.edit {
394394
delete(currentLineStart, currentLineEnd)
@@ -404,7 +404,12 @@ fun StandardTextField(
404404
?: 1
405405
"$nextNumber. " // 有序列表
406406
}
407-
407+
trimmedLine.matches(Regex("^\\d+\\)\\s.*")) -> {
408+
val nextNumber =
409+
trimmedLine.substringBefore(")").toIntOrNull()?.plus(1)
410+
?: 1
411+
"$nextNumber) " // 有序列表
412+
}
408413
trimmedLine.startsWith("- ") -> "- " // 无序列表
409414
trimmedLine.startsWith("* ") -> "* "
410415
trimmedLine.startsWith("+ ") -> "+ "

0 commit comments

Comments
 (0)