From 64ffbc142e37cb8b58fefc20050b7c94f6f021c7 Mon Sep 17 00:00:00 2001 From: anijanyan Date: Sun, 29 Dec 2024 18:39:05 +0400 Subject: [PATCH] aligned_diff style by default is solid gray instead of zebra, fold syncing --- diff0/styles.css | 15 ++++++++------- diff0/twoway.js | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/diff0/styles.css b/diff0/styles.css index bd8c0ea2ff..3a95f313ba 100644 --- a/diff0/styles.css +++ b/diff0/styles.css @@ -96,13 +96,14 @@ background-color: rgba(255, 128, 79, 0.26); } .ace_diff.aligned_diff.inline:after { - background: repeating-linear-gradient( - 45deg, /* Angle of the stripes */ - rgba(122, 111, 108, 0.26), /* First color */ - rgba(122, 111, 108, 0.26) 5px, /* Stripe width */ - #FFFFFF 5px, /* Second color starts */ - #FFFFFF 10px /* Second stripe width */ - ); + background: rgba(206, 194, 191, 0.26); + /*background: repeating-linear-gradient(*/ + /* 45deg, !* Angle of the stripes *!*/ + /* rgba(122, 111, 108, 0.26), !* First color *!*/ + /* rgba(122, 111, 108, 0.26) 5px, !* Stripe width *!*/ + /* #FFFFFF 5px, !* Second color starts *!*/ + /* #FFFFFF 10px !* Second stripe width *!*/ + /*);*/ } .ace_diff.delete.inline.empty { diff --git a/diff0/twoway.js b/diff0/twoway.js index 4f3436c4b5..188618e7a5 100644 --- a/diff0/twoway.js +++ b/diff0/twoway.js @@ -417,14 +417,43 @@ class DiffView { } onChangeFold(ev, session) { - if (ev.action == "remove") { - var other = session == this.orig.session ? this.edit.session : this.orig.session; - var fold = ev.data; - if (fold && fold.other) { + var fold = ev.data; + if (this.$syncFold || !fold || !ev.action) + return; + + const isOrig = session === this.orig.session; + const other = isOrig ? this.edit.session : this.orig.session; + + if (ev.action === "remove") { + if (fold.other) { fold.other.other = null; other.removeFold(fold.other); + } else if (fold.lineWidget) { + other.widgetManager.addLineWidget(fold.lineWidget); + fold.lineWidget = null; + other.$editor.renderer.updateBackMarkers(); } } + + if (ev.action === "add") { + const range = this.transformRange(fold.range, isOrig); + if (range.isEmpty()) { + const row = range.start.row + 1; + if (other.lineWidgets[row]) { + fold.lineWidget = other.lineWidgets[row]; + other.widgetManager.removeLineWidget(fold.lineWidget); + other.$editor.renderer.updateBackMarkers(); + } + } else { + this.$syncFold = true; + + fold.other = other.addFold("---", range); + fold.other.other = fold; + + this.$syncFold = false; + + } + } } $attachEditorsEventHandlers() { @@ -639,7 +668,6 @@ class SyncSelectionMarker { this.range = newRange; } - } class DiffHighlight {