Skip to content

Commit 6377157

Browse files
shumadridVinzent03
andauthored
feat: collapse unchanged lines in split diff view (#893)
* feat: collapse unchanged lines in split diff view * refactor: increase sizes * fix: better styling --------- Co-authored-by: Vinzent <vinzent03@proton.me>
1 parent 2d2ebfd commit 6377157

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/ui/diff/splitDiffView.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import { SimpleGit } from "src/gitManager/simpleGit";
55
import type ObsidianGit from "src/main";
66
import type { DiffViewState } from "src/types";
77

8+
import { history, indentWithTab, standardKeymap } from "@codemirror/commands";
9+
import { MergeView } from "@codemirror/merge";
10+
import { highlightSelectionMatches, search } from "@codemirror/search";
11+
import { EditorState, Transaction } from "@codemirror/state";
812
import {
913
drawSelection,
1014
EditorView,
1115
keymap,
1216
lineNumbers,
1317
ViewPlugin,
1418
} from "@codemirror/view";
15-
import { EditorState, Transaction } from "@codemirror/state";
16-
import { MergeView } from "@codemirror/merge";
17-
import { history, indentWithTab, standardKeymap } from "@codemirror/commands";
18-
import { highlightSelectionMatches, search } from "@codemirror/search";
1919
import { GitError } from "simple-git";
2020

2121
// This class is not extending `FileView', because it needs a `TFile`, which is not possible for dot files like `.gitignore`, which this editor should support as well.`
@@ -358,6 +358,10 @@ export default class SplitDiffView extends ItemView {
358358
this.mergeView = new MergeView({
359359
b: bState,
360360
a: aState,
361+
collapseUnchanged: {
362+
minSize: 6,
363+
margin: 4,
364+
},
361365
diffConfig: {
362366
scanLimit: this.bIsEditable ? 1000 : 10000, // default is 500
363367
},

styles.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,3 +590,16 @@
590590
.git-obscure-prompt[git-is-obscured="false"] #git-show-password:after {
591591
-webkit-mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="svg-icon lucide-eye-off"><path d="M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"></path><path d="M14.084 14.158a3 3 0 0 1-4.242-4.242"></path><path d="M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"></path><path d="m2 2 20 20"></path></svg>');
592592
}
593+
594+
/* Override styling of Codemirror merge view "collapsed lines" indicator */
595+
.git-split-diff-view .ͼ2 .cm-collapsedLines {
596+
background: var(--interactive-normal);
597+
border-radius: var(--radius-m);
598+
color: var(--text-accent);
599+
font-size: var(--font-small);
600+
padding: var(--size-4-1) var(--size-4-1);
601+
}
602+
.git-split-diff-view .ͼ2 .cm-collapsedLines:hover {
603+
background: var(--interactive-hover);
604+
color: var(--text-accent-hover);
605+
}

0 commit comments

Comments
 (0)