mirror of
https://github.com/kuhyx/todo-app.git
synced 2026-11-22 18:32:22 +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.dart';
|
||||||
import 'package:todo/data/note_repository.dart';
|
import 'package:todo/data/note_repository.dart';
|
||||||
import 'package:todo/data/note_template.dart';
|
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
/// Statuses that count as open.
|
/// 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;
|
Priority maxPriority(Priority a, Priority b) => a.value >= b.value ? a : b;
|
||||||
|
|
||||||
/// Title line and rest of a note's text.
|
/// Title line and rest of a note's text.
|
||||||
({String title, String body}) splitNote(String text) =>
|
({String title, String body}) splitNote(String text) {
|
||||||
(title: noteTitle(text), body: text.split('\n').skip(1).join('\n').trim());
|
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.
|
/// Oldest first; ties broken by id so the choice is deterministic.
|
||||||
int byAge(Note a, Note b) {
|
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
|
# 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
|
# 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.
|
# 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:
|
environment:
|
||||||
sdk: ^3.12.2
|
sdk: ^3.12.2
|
||||||
|
|||||||
@ -41,6 +41,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('splitNote of blank text is empty', () {
|
||||||
|
expect(splitNote(' \n'), (title: '', body: ''));
|
||||||
|
});
|
||||||
|
|
||||||
group('addRepoTask', () {
|
group('addRepoTask', () {
|
||||||
late NoteRepository repo;
|
late NoteRepository repo;
|
||||||
setUp(() async => repo = await NoteRepository.openInMemory());
|
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', () {
|
test('closed notes and plain ideas are ignored', () {
|
||||||
final idea = Note(
|
final idea = Note(
|
||||||
id: 'i',
|
id: 'i',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user