mirror of
https://github.com/friebetill/obsidian-file-diff.git
synced 2026-07-22 07:40:25 +00:00
Scroll automatically to differences
This commit is contained in:
parent
b2a91f2670
commit
525b7bf9ae
1 changed files with 17 additions and 1 deletions
|
|
@ -91,7 +91,10 @@ export class DifferencesView extends ItemView {
|
|||
)
|
||||
|
||||
if (difference != null) {
|
||||
this.buildDifferenceVisualizer(container, difference)
|
||||
const differenceContainer = container.createDiv({
|
||||
cls: 'difference',
|
||||
})
|
||||
this.buildDifferenceVisualizer(differenceContainer, difference)
|
||||
}
|
||||
if (
|
||||
line != null &&
|
||||
|
|
@ -105,6 +108,19 @@ export class DifferencesView extends ItemView {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.fileDifferences.differences.length > 0) {
|
||||
const containerRect = this.contentEl
|
||||
.getElementsByClassName('container')[0]
|
||||
.getBoundingClientRect()
|
||||
const elementRect = this.contentEl
|
||||
.getElementsByClassName('difference')[0]
|
||||
.getBoundingClientRect()
|
||||
this.contentEl.scrollTo({
|
||||
top: elementRect.top - containerRect.top - 100,
|
||||
behavior: 'smooth',
|
||||
})
|
||||
}
|
||||
|
||||
if (
|
||||
this.fileDifferences.differences.length === 0 &&
|
||||
this.showMergeOption &&
|
||||
|
|
|
|||
Loading…
Reference in a new issue