Skip to content

feat: collapse unchanged lines in split diff view #893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/ui/diff/splitDiffView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import { SimpleGit } from "src/gitManager/simpleGit";
import type ObsidianGit from "src/main";
import type { DiffViewState } from "src/types";

import { history, indentWithTab, standardKeymap } from "@codemirror/commands";
import { MergeView } from "@codemirror/merge";
import { highlightSelectionMatches, search } from "@codemirror/search";
import { EditorState, Transaction } from "@codemirror/state";
import {
drawSelection,
EditorView,
keymap,
lineNumbers,
ViewPlugin,
} from "@codemirror/view";
import { EditorState, Transaction } from "@codemirror/state";
import { MergeView } from "@codemirror/merge";
import { history, indentWithTab, standardKeymap } from "@codemirror/commands";
import { highlightSelectionMatches, search } from "@codemirror/search";
import { GitError } from "simple-git";

// 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.`
Expand Down Expand Up @@ -358,6 +358,10 @@ export default class SplitDiffView extends ItemView {
this.mergeView = new MergeView({
b: bState,
a: aState,
collapseUnchanged: {
minSize: 6,
margin: 4,
},
diffConfig: {
scanLimit: this.bIsEditable ? 1000 : 10000, // default is 500
},
Expand Down
13 changes: 13 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,16 @@
.git-obscure-prompt[git-is-obscured="false"] #git-show-password:after {
-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>');
}

/* Override styling of Codemirror merge view "collapsed lines" indicator */
.git-split-diff-view .ͼ2 .cm-collapsedLines {
background: var(--interactive-normal);
border-radius: var(--radius-m);
color: var(--text-accent);
font-size: var(--font-small);
padding: var(--size-4-1) var(--size-4-1);
}
.git-split-diff-view .ͼ2 .cm-collapsedLines:hover {
background: var(--interactive-hover);
color: var(--text-accent-hover);
}