This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-09 16:37:40 -05:00
1 parent 27d404ba59
commit c5d4bf76a5
12 files changed
+461 -324

No files matched your search

@@ -0,0 +1,29 @@
import { writable } from 'svelte/store';
const HIDE_WHITESPACE_KEY = 'gitDiff:hideWhitespace';
const DISPLAY_MODE_KEY = 'gitDiff:displayMode';
export type DiffDisplayMode = 'unified' | 'split';
function persistedBoolean(key: string, fallback: boolean) {
const initial =
typeof localStorage !== 'undefined' ? localStorage.getItem(key) === 'true' : fallback;
const store = writable(initial);
store.subscribe((value) => {
if (typeof localStorage !== 'undefined') localStorage.setItem(key, String(value));
});
return store;
}
export const hideWhitespaceChanges = persistedBoolean(HIDE_WHITESPACE_KEY, false);
const initialDisplayMode =
typeof localStorage !== 'undefined'
? localStorage.getItem(DISPLAY_MODE_KEY) === 'split'
? 'split'
: 'unified'
: 'unified';
export const diffDisplayMode = writable<DiffDisplayMode>(initialDisplayMode);
diffDisplayMode.subscribe((value) => {
if (typeof localStorage !== 'undefined') localStorage.setItem(DISPLAY_MODE_KEY, value);
});