diff --git a/lib/data/layout_prefs.dart b/lib/data/layout_prefs.dart index 6d5a4f1..dd156f1 100644 --- a/lib/data/layout_prefs.dart +++ b/lib/data/layout_prefs.dart @@ -147,7 +147,7 @@ class LayoutPrefs extends ChangeNotifier { bool _readyToTypeOnOpen = true; bool _dailySeparatorsEnabled = true; bool _spellCheckEnabled = true; - bool _markdownEnabled = false; + bool _markdownEnabled = true; NumberSystem _numberSystem = NumberSystem.auto; WritingFont _writingFont = WritingFont.clean; double _editorTextScale = defaultEditorTextScale; @@ -204,9 +204,11 @@ class LayoutPrefs extends ChangeNotifier { /// Whether notes are written in markdown: `# `, `**`, `- ` and the rest /// drawn as what they mean, and the formatting controls writing them. /// - /// Off by default, and a matter of how this device shows and edits notes + /// On by default, and a matter of how this device shows and edits notes /// rather than of the notes: nothing is converted either way, so switching - /// it back leaves every note exactly as it was written. + /// it back leaves every note exactly as it was written. The setting is only + /// stored once the writer changes it, so a device that has never stored it + /// gets markdown, and one that switched it off keeps it off. bool get markdownEnabled => _markdownEnabled; WritingFont get writingFont => _writingFont; @@ -345,7 +347,7 @@ class LayoutPrefs extends ChangeNotifier { _readyToTypeOnOpen = _store.read(_readyToTypeOnOpenKey) ?? true; _dailySeparatorsEnabled = _store.read(_dailySeparatorsKey) ?? true; _spellCheckEnabled = _store.read(_spellCheckKey) ?? true; - _markdownEnabled = _store.read(_markdownKey) ?? false; + _markdownEnabled = _store.read(_markdownKey) ?? true; _numberSystem = _readNumberSystem(); _writingFont = _readWritingFont(); _editorTextScale = _normalizeEditorTextScale( diff --git a/test/goldens/phone_settings_general.png b/test/goldens/phone_settings_general.png index 3058553..849d6ce 100644 Binary files a/test/goldens/phone_settings_general.png and b/test/goldens/phone_settings_general.png differ diff --git a/test/preferences_test.dart b/test/preferences_test.dart index 8b25ec5..9a73108 100644 --- a/test/preferences_test.dart +++ b/test/preferences_test.dart @@ -336,18 +336,29 @@ void main() { ); }); - test('markdown in notes starts off, and a yes survives reload', () { + test('markdown in notes starts on, and a no survives reload', () { final store = _MemoryStore(); final prefs = LayoutPrefs(store)..load(); - expect(prefs.markdownEnabled, isFalse); + expect(prefs.markdownEnabled, isTrue); var notified = 0; prefs.addListener(() => notified++); - prefs.markdownEnabled = true; - prefs.markdownEnabled = true; + prefs.markdownEnabled = false; + prefs.markdownEnabled = false; expect(notified, 1); - expect((LayoutPrefs(store)..load()).markdownEnabled, isTrue); + expect((LayoutPrefs(store)..load()).markdownEnabled, isFalse); + }); + + test('markdown in notes follows what this device stored, if anything', () { + final never = _MemoryStore(); + expect((LayoutPrefs(never)..load()).markdownEnabled, isTrue); + + final switchedOff = _MemoryStore()..put('markdownInNotes.v1', false); + expect((LayoutPrefs(switchedOff)..load()).markdownEnabled, isFalse); + + final switchedOn = _MemoryStore()..put('markdownInNotes.v1', true); + expect((LayoutPrefs(switchedOn)..load()).markdownEnabled, isTrue); }); test('time zone selection converts timestamps and survives reload', () { diff --git a/test/settings_sheet_test.dart b/test/settings_sheet_test.dart index cb28ca3..3781f91 100644 --- a/test/settings_sheet_test.dart +++ b/test/settings_sheet_test.dart @@ -178,15 +178,15 @@ void main() { find.descendant(of: toggle, matching: find.text('Markdown in notes')), findsOneWidget, ); - expect(prefs.markdownEnabled, isFalse); + expect(prefs.markdownEnabled, isTrue); await tester.tap(toggle); await tester.pumpAndSettle(); - expect(prefs.markdownEnabled, isTrue); + expect(prefs.markdownEnabled, isFalse); await tester.tap(toggle); await tester.pumpAndSettle(); - expect(prefs.markdownEnabled, isFalse); + expect(prefs.markdownEnabled, isTrue); }); testWidgets('the back gesture leaves the category before the sheet', (