Skip to content

Commit da23041

Browse files
silverwindzeripath
authored andcommitted
fix extra newlines when copying from diff in Firefox (#7288)
* fix extra newlines when copying from diff See https://bugzilla.mozilla.org/show_bug.cgi?id=1273836 Basically, the <pre><code> seems to add a forced newline that is not possible to get rid of via CSS, so I replaced it with just a <code>. Secondly, .lines-type-marker also forced a newline in the copied text, but that was possible to get rid of via user-select. Safari still has a extraneous newline in the copied text of unknown origin, but this should not block stop this PR. * simplify .line-type-marker * fix selector * remove erronous ^^^ * Fix empty split diff * Fix arc-theme-green * fix add comment * ensure line-num is copied too * Update templates/repo/diff/box.tmpl Co-Authored-By: zeripath <[email protected]> * attempt to fix safari via removing <code> * remove useless whitespace at the end of 'class' * remove inter-tag whitespace for code <td>s * more inter-tag removal * final inter-tag removal * attempt to fix empty line copy * move and comment getLineContent * fix golint * make background grey for missing added code
1 parent edc94c7 commit da23041

File tree

9 files changed

+59
-74
lines changed

9 files changed

+59
-74
lines changed

models/git_diff.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ func (d *DiffLine) GetLineTypeMarker() string {
8888
return ""
8989
}
9090

91+
// escape a line's content or return <br> needed for copy/paste purposes
92+
func getLineContent(content string) string {
93+
if len(content) > 0 {
94+
return html.EscapeString(content)
95+
}
96+
return "<br>"
97+
}
98+
9199
// DiffSection represents a section of a DiffFile.
92100
type DiffSection struct {
93101
Name string
@@ -107,14 +115,14 @@ func diffToHTML(diffs []diffmatchpatch.Diff, lineType DiffLineType) template.HTM
107115
switch {
108116
case diffs[i].Type == diffmatchpatch.DiffInsert && lineType == DiffLineAdd:
109117
buf.Write(addedCodePrefix)
110-
buf.WriteString(html.EscapeString(diffs[i].Text))
118+
buf.WriteString(getLineContent(diffs[i].Text))
111119
buf.Write(codeTagSuffix)
112120
case diffs[i].Type == diffmatchpatch.DiffDelete && lineType == DiffLineDel:
113121
buf.Write(removedCodePrefix)
114-
buf.WriteString(html.EscapeString(diffs[i].Text))
122+
buf.WriteString(getLineContent(diffs[i].Text))
115123
buf.Write(codeTagSuffix)
116124
case diffs[i].Type == diffmatchpatch.DiffEqual:
117-
buf.WriteString(html.EscapeString(diffs[i].Text))
125+
buf.WriteString(getLineContent(diffs[i].Text))
118126
}
119127
}
120128

@@ -173,7 +181,7 @@ func init() {
173181
// GetComputedInlineDiffFor computes inline diff for the given line.
174182
func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) template.HTML {
175183
if setting.Git.DisableDiffHighlight {
176-
return template.HTML(html.EscapeString(diffLine.Content[1:]))
184+
return template.HTML(getLineContent(diffLine.Content[1:]))
177185
}
178186
var (
179187
compareDiffLine *DiffLine
@@ -186,22 +194,22 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) tem
186194
case DiffLineAdd:
187195
compareDiffLine = diffSection.GetLine(DiffLineDel, diffLine.RightIdx)
188196
if compareDiffLine == nil {
189-
return template.HTML(html.EscapeString(diffLine.Content[1:]))
197+
return template.HTML(getLineContent(diffLine.Content[1:]))
190198
}
191199
diff1 = compareDiffLine.Content
192200
diff2 = diffLine.Content
193201
case DiffLineDel:
194202
compareDiffLine = diffSection.GetLine(DiffLineAdd, diffLine.LeftIdx)
195203
if compareDiffLine == nil {
196-
return template.HTML(html.EscapeString(diffLine.Content[1:]))
204+
return template.HTML(getLineContent(diffLine.Content[1:]))
197205
}
198206
diff1 = diffLine.Content
199207
diff2 = compareDiffLine.Content
200208
default:
201209
if strings.IndexByte(" +-", diffLine.Content[0]) > -1 {
202-
return template.HTML(html.EscapeString(diffLine.Content[1:]))
210+
return template.HTML(getLineContent(diffLine.Content[1:]))
203211
}
204-
return template.HTML(html.EscapeString(diffLine.Content))
212+
return template.HTML(getLineContent(diffLine.Content))
205213
}
206214

207215
diffRecord := diffMatchPatch.DiffMain(diff1[1:], diff2[1:], true)

public/css/index.css

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ img{border-radius:3px}
4747
table{border-collapse:collapse}
4848
a{cursor:pointer}
4949
.rounded{border-radius:.28571429rem!important}
50-
code,pre{font:12px 'SF Mono',Consolas,Menlo,'Liberation Mono',Monaco,'Lucida Console',monospace}
51-
code.raw,pre.raw{padding:7px 12px;margin:10px 0;background-color:#f8f8f8;border:1px solid #ddd;border-radius:3px;font-size:13px;line-height:1.5;overflow:auto}
52-
code.wrap,pre.wrap{white-space:pre-wrap;word-break:break-all;overflow-wrap:break-word;word-wrap:break-word}
50+
.mono,code,pre{font:12px 'SF Mono',Consolas,Menlo,'Liberation Mono',Monaco,'Lucida Console',monospace}
51+
.mono.raw,code.raw,pre.raw{padding:7px 12px;margin:10px 0;background-color:#f8f8f8;border:1px solid #ddd;border-radius:3px;font-size:13px;line-height:1.5;overflow:auto}
52+
.mono.wrap,code.wrap,pre.wrap{white-space:pre-wrap;word-break:break-all;overflow-wrap:break-word;word-wrap:break-word}
5353
.dont-break-out{overflow-wrap:break-word;word-wrap:break-word;word-break:break-all;-webkit-hyphens:auto;-ms-hyphens:auto;hyphens:auto}
5454
.full.height{flex-grow:1;padding-bottom:80px}
5555
.following.bar{z-index:900;left:0;margin:0!important}
@@ -638,19 +638,18 @@ footer .ui.left,footer .ui.right{line-height:40px}
638638
.repository .diff-file-box .file-body.file-code .lines-num-old{border-right:1px solid #ddd}
639639
.repository .diff-file-box .code-diff{font-size:12px}
640640
.repository .diff-file-box .code-diff td{padding:0 0 0 10px;border-top:0}
641-
.repository .diff-file-box .code-diff pre{margin:0}
642641
.repository .diff-file-box .code-diff .lines-num{border-color:#d4d4d5;border-right-width:1px;border-right-style:solid;padding:0 5px}
643642
.repository .diff-file-box .code-diff tbody tr td.halfwidth{width:49%}
644643
.repository .diff-file-box .code-diff tbody tr td.tag-code,.repository .diff-file-box .code-diff tbody tr.tag-code td{background-color:#f0f0f0!important;border-color:#d3cfcf!important;padding-top:8px;padding-bottom:8px}
645644
.repository .diff-file-box .code-diff tbody tr .removed-code{background-color:#f99}
646645
.repository .diff-file-box .code-diff tbody tr .added-code{background-color:#9f9}
647-
.repository .diff-file-box .code-diff tbody tr .lines-num[data-line-num]::before{content:attr(data-line-num);text-align:right}
648-
.repository .diff-file-box .code-diff tbody tr .lines-type-marker{width:10px;min-width:10px}
649-
.repository .diff-file-box .code-diff tbody tr .line-type-marker[data-type-marker]::before{content:attr(data-type-marker);text-align:right;display:inline-block}
646+
.repository .diff-file-box .code-diff tbody tr [data-line-num]::before{content:attr(data-line-num);text-align:right}
647+
.repository .diff-file-box .code-diff tbody tr .lines-type-marker{width:10px;min-width:10px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
648+
.repository .diff-file-box .code-diff tbody tr [data-type-marker]::before{content:attr(data-type-marker);text-align:right;display:inline-block}
650649
.repository .diff-file-box .code-diff-unified tbody tr.del-code td{background-color:#ffe0e0!important;border-color:#f1c0c0!important}
651650
.repository .diff-file-box .code-diff-unified tbody tr.add-code td{background-color:#d6fcd6!important;border-color:#c1e9c1!important}
652651
.repository .diff-file-box .code-diff-split table,.repository .diff-file-box .code-diff-split tbody{width:100%}
653-
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(1),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(2),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(3),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(4),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(5),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(6){background-color:#fafafa}
652+
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(1),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(2),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(3),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(4),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(5),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(6){background-color:#fafafa}
654653
.repository .diff-file-box .code-diff-split tbody tr td.del-code,.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(1),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(2),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(3){background-color:#ffe0e0!important;border-color:#f1c0c0!important}
655654
.repository .diff-file-box .code-diff-split tbody tr td.add-code,.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(4),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(5),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(6){background-color:#d6fcd6!important;border-color:#c1e9c1!important}
656655
.repository .diff-file-box .code-diff-split tbody tr td:nth-child(4){border-left-width:1px;border-left-style:solid}

public/css/theme-arc-green.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ a.ui.label:hover,a.ui.labels .label:hover{background-color:#505667;color:#dbdbdb
216216
.ui.basic.blue.button,.ui.basic.blue.buttons .button{box-shadow:0 0 0 1px #a27558 inset!important;color:#a27558!important}
217217
.repository.file.list #file-content .code-view .hljs,.repository.file.list #file-content .code-view .lines-code ol,.repository.file.list #file-content .code-view .lines-code pre,.repository.file.list #file-content .code-view .lines-num .hljs,.repository.file.list #file-content .code-view .lines-num ol,.repository.file.list #file-content .code-view .lines-num pre{background-color:#2a2e3a}
218218
a.ui.label:hover,a.ui.labels .label:hover{background-color:#505667;color:#dbdbdb}
219-
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(1),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(2),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(3),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(4){background-color:#2a2e3a}
220-
.repository .diff-file-box .code-diff-split tbody tr td.add-code,.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(3),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(4){background-color:#283e2d!important;border-color:#314a37!important}
221-
.repository .diff-file-box .code-diff-split tbody tr td.del-code,.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(1),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(2){background-color:#3c2626!important;border-color:#634343!important}
219+
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(1),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(2),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(3),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(4),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(5),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(6){background-color:#2a2e3a}
220+
.repository .diff-file-box .code-diff-split tbody tr td.add-code,.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(4),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(5),.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(6){background-color:#283e2d!important;border-color:#314a37!important}
221+
.repository .diff-file-box .code-diff-split tbody tr td.del-code,.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(1),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(2),.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(3){background-color:#3c2626!important;border-color:#634343!important}
222222
.ui.blue.button:focus,.ui.blue.buttons .button:focus{background-color:#a27558}
223223
.ui.blue.button:active,.ui.blue.buttons .button:active{background-color:#a27558}
224224
#git-graph-container li a{color:#c79575}

public/js/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,8 +1069,8 @@ function initPullRequestReview() {
10691069
var ntr = tr.next();
10701070
if (!ntr.hasClass('add-comment')) {
10711071
ntr = $('<tr class="add-comment">'
1072-
+ (isSplit ? '<td class="lines-num"></td><td class="add-comment-left"></td><td class="lines-num"></td><td class="add-comment-right"></td>'
1073-
: '<td class="lines-num"></td><td class="lines-num"></td><td class="add-comment-left add-comment-right"></td>')
1072+
+ (isSplit ? '<td class="lines-num"></td><td class="lines-type-marker"></td><td class="add-comment-left"></td><td class="lines-num"></td><td class="lines-type-marker"></td><td class="add-comment-right"></td>'
1073+
: '<td class="lines-num"></td><td class="lines-num"></td><td class="lines-type-marker"></td><td class="add-comment-left add-comment-right"></td>')
10741074
+ '</tr>');
10751075
tr.after(ntr);
10761076
}

public/less/_base.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ a {
160160
}
161161

162162
pre,
163-
code {
163+
code,
164+
.mono {
164165
font: 12px @monospaced-fonts, monospace;
165166

166167
&.raw {

public/less/_repository.less

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,10 +1362,6 @@
13621362
border-top: 0;
13631363
}
13641364

1365-
pre {
1366-
margin: 0;
1367-
}
1368-
13691365
.lines-num {
13701366
border-color: #d4d4d5;
13711367
border-right-width: 1px;
@@ -1405,17 +1401,18 @@
14051401
background-color: #99ff99;
14061402
}
14071403

1408-
.lines-num[data-line-num]::before {
1404+
[data-line-num]::before {
14091405
content: attr(data-line-num);
14101406
text-align: right;
14111407
}
14121408

14131409
.lines-type-marker {
14141410
width: 10px;
14151411
min-width: 10px;
1412+
user-select: none;
14161413
}
14171414

1418-
.line-type-marker[data-type-marker]::before {
1415+
[data-type-marker]::before {
14191416
content: attr(data-type-marker);
14201417
text-align: right;
14211418
display: inline-block;
@@ -1448,7 +1445,7 @@
14481445
// light gray for empty lines before / after commit
14491446
&.add-code td:nth-child(1),
14501447
&.add-code td:nth-child(2),
1451-
&.del-code td:nth-child(3),
1448+
&.add-code td:nth-child(3),
14521449
&.del-code td:nth-child(4),
14531450
&.del-code td:nth-child(5),
14541451
&.del-code td:nth-child(6) {

public/less/themes/arc-green.less

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,19 +1115,23 @@ a.ui.labels .label:hover {
11151115
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(1),
11161116
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(2),
11171117
.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(3),
1118-
.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(4) {
1118+
.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(4),
1119+
.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(5),
1120+
.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(6) {
11191121
background-color: #2a2e3a;
11201122
}
11211123

1122-
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(3),
11231124
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(4),
1125+
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(5),
1126+
.repository .diff-file-box .code-diff-split tbody tr.add-code td:nth-child(6),
11241127
.repository .diff-file-box .code-diff-split tbody tr td.add-code {
11251128
background-color: #283e2d !important;
11261129
border-color: #314a37 !important;
11271130
}
11281131

11291132
.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(1),
11301133
.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(2),
1134+
.repository .diff-file-box .code-diff-split tbody tr.del-code td:nth-child(3),
11311135
.repository .diff-file-box .code-diff-split tbody tr td.del-code {
11321136
background-color: #3c2626 !important;
11331137
border-color: #634343 !important;

templates/repo/diff/box.tmpl

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -120,30 +120,12 @@
120120
{{range $j, $section := $file.Sections}}
121121
{{range $k, $line := $section.Lines}}
122122
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
123-
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}">
124-
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span>
125-
</td>
126-
<td class="lines-type-marker">
127-
<pre>{{if $line.LeftIdx}}<span class="line-type-marker" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</pre>
128-
</td>
129-
<td class="lines-code lines-code-old halfwidth">
130-
{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}
131-
<a class="ui green button add-code-comment add-code-comment-left" data-path="{{$file.Name}}" data-side="left" data-idx="{{$line.LeftIdx}}">+</a>
132-
{{end}}
133-
<pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
134-
</td>
135-
<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}">
136-
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span>
137-
</td>
138-
<td class="lines-type-marker">
139-
<pre>{{if $line.RightIdx}}<span class="line-type-marker" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</pre>
140-
</td>
141-
<td class="lines-code lines-code-new halfwidth">
142-
{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}
143-
<a class="ui green button add-code-comment add-code-comment-right" data-path="{{$file.Name}}" data-side="right" data-idx="{{$line.RightIdx}}">+</a>
144-
{{end}}
145-
<pre><code class="wrap {{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</code></pre>
146-
</td>
123+
<td class="lines-num lines-num-old" data-line-num="{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}"><span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}"></span></td>
124+
<td class="lines-type-marker lines-type-marker-old">{{if $line.LeftIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
125+
<td class="lines-code lines-code-old halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 2))}}<a class="ui green button add-code-comment add-code-comment-left" data-path="{{$file.Name}}" data-side="left" data-idx="{{$line.LeftIdx}}">+</a>{{end}}<span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.LeftIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
126+
<td class="lines-num lines-num-new" data-line-num="{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}"><span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}"></span></td>
127+
<td class="lines-type-marker lines-type-marker-new">{{if $line.RightIdx}}<span class="mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span>{{end}}</td>
128+
<td class="lines-code lines-code-new halfwidth">{{if and $.SignedUserID $line.CanComment $.PageIsPullFiles (not (eq .GetType 3))}}<a class="ui green button add-code-comment add-code-comment-right" data-path="{{$file.Name}}" data-side="right" data-idx="{{$line.RightIdx}}">+</a>{{end}}<span class="mono wrap{{if $highlightClass}} language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{if $line.RightIdx}}{{$section.GetComputedInlineDiffFor $line}}{{end}}</span></td>
147129
</tr>
148130
{{if gt (len $line.Comments) 0}}
149131
<tr class="add-code-comment">
@@ -230,17 +212,22 @@
230212
document.addEventListener('DOMContentLoaded', function() {
231213
$('tr.add-code').each(function() {
232214
var prev = $(this).prev();
233-
if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
234-
while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
215+
if(prev.is('.del-code') && prev.children().eq(5).text().trim() === '') {
216+
while(prev.prev().is('.del-code') && prev.prev().children().eq(5).text().trim() === '') {
235217
prev = prev.prev();
236218
}
237-
prev.children().eq(2).html($(this).children().eq(2).html());
219+
prev.children().eq(3).attr("data-line-num", $(this).children().eq(3).attr("data-line-num"));
238220
prev.children().eq(3).html($(this).children().eq(3).html());
221+
prev.children().eq(4).html($(this).children().eq(4).html());
222+
prev.children().eq(5).html($(this).children().eq(5).html());
239223

240224
prev.children().eq(0).addClass('del-code');
241225
prev.children().eq(1).addClass('del-code');
242-
prev.children().eq(2).addClass('add-code');
226+
prev.children().eq(2).addClass('del-code');
243227
prev.children().eq(3).addClass('add-code');
228+
prev.children().eq(4).addClass('add-code');
229+
prev.children().eq(5).addClass('add-code');
230+
244231
$(this).remove();
245232
}
246233
});

0 commit comments

Comments
 (0)