mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-10 20:07:02 +01:00
Split notes on first non-blank line
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
file-length / file length <= 250 lines (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
release-apk / release (APK) (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cbe3d9be59
commit
a0c1938d8d
@ -4,7 +4,6 @@ library;
|
||||
|
||||
import 'package:todo/data/note.dart';
|
||||
import 'package:todo/data/note_repository.dart';
|
||||
import 'package:todo/data/note_template.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
|
||||
/// Statuses that count as open.
|
||||
@ -31,8 +30,15 @@ String repoSection(String title, String body) {
|
||||
Priority maxPriority(Priority a, Priority b) => a.value >= b.value ? a : b;
|
||||
|
||||
/// Title line and rest of a note's text.
|
||||
({String title, String body}) splitNote(String text) =>
|
||||
(title: noteTitle(text), body: text.split('\n').skip(1).join('\n').trim());
|
||||
({String title, String body}) splitNote(String text) {
|
||||
final lines = text.split('\n');
|
||||
final first = lines.indexWhere((l) => l.trim().isNotEmpty);
|
||||
if (first < 0) return (title: '', body: '');
|
||||
return (
|
||||
title: lines[first].trim().replaceFirst(RegExp(r'^#+\s*'), ''),
|
||||
body: lines.skip(first + 1).join('\n').trim(),
|
||||
);
|
||||
}
|
||||
|
||||
/// Oldest first; ties broken by id so the choice is deterministic.
|
||||
int byAge(Note a, Note b) {
|
||||
|
||||
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.0.57+1
|
||||
version: 1.0.58+1
|
||||
|
||||
environment:
|
||||
sdk: ^3.12.2
|
||||
|
||||
@ -41,6 +41,10 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
test('splitNote of blank text is empty', () {
|
||||
expect(splitNote(' \n'), (title: '', body: ''));
|
||||
});
|
||||
|
||||
group('addRepoTask', () {
|
||||
late NoteRepository repo;
|
||||
setUp(() async => repo = await NoteRepository.openInMemory());
|
||||
@ -165,6 +169,11 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('a leading blank line and a # prefix do not leak into sections', () {
|
||||
final plan = planRepoMerges([_n('a', '\n# Title\nbody')]);
|
||||
expect(plan.single.kept.text, 'wake-alarm todos\n\n## Title\nbody');
|
||||
});
|
||||
|
||||
test('closed notes and plain ideas are ignored', () {
|
||||
final idea = Note(
|
||||
id: 'i',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user