feat: add tabSize user setting

This commit is contained in:
Mayfield 2024-03-23 20:27:47 -04:00
parent 02dcc3f1e7
commit f940d6a1cf
No known key found for this signature in database
2 changed files with 14 additions and 3 deletions

View File

@ -1,9 +1,12 @@
<script lang="ts">
import { create } from '$lib/components/Differ/CodeHighlighter';
import { SETTINGS_CONTEXT, type SettingsStore } from '$lib/settings/userSettings';
import { SectionType } from '$lib/utils/fileSections';
import { createEventDispatcher } from 'svelte';
import { createEventDispatcher, getContext } from 'svelte';
import type { Line } from '$lib/utils/fileSections';
const userSettings = getContext(SETTINGS_CONTEXT) as SettingsStore;
export let line: Line;
export let sectionType: SectionType;
export let filePath: string;
@ -40,7 +43,12 @@
: 'bg-light-50 border-light-300 dark:bg-dark-700 dark:border-dark-400';
</script>
<div class="code-line text-sm" role="group" on:contextmenu|preventDefault>
<div
class="code-line text-sm"
role="group"
style="--tab-size: {$userSettings.tabSize}"
on:contextmenu|preventDefault
>
<div class="code-line__numbers-line">
<button
on:click={() => selectable && dispatch('selected', !selected)}
@ -80,6 +88,7 @@
font-family: monospace;
background-color: var(----clr-theme-container-light);
white-space: pre;
tab-size: var(--tab-size);
}
.line {

View File

@ -16,6 +16,7 @@ export interface Settings {
defaultTreeHeight: number;
zoom: number;
scrollbarVisabilityOnHover: boolean;
tabSize: number;
}
const defaults: Settings = {
@ -29,7 +30,8 @@ const defaults: Settings = {
defaultTreeHeight: 100,
stashedBranchesHeight: 150,
zoom: 1,
scrollbarVisabilityOnHover: false
scrollbarVisabilityOnHover: false,
tabSize: 4
};
export type SettingsStore = Writable<Settings>;