@@ -15,6 +15,19 @@ function getCodeMarker(type: DiffType) {
15
15
return ' +'
16
16
return ' '
17
17
}
18
+
19
+ function onSplitLineMousedown(side : ' left' | ' right' ) {
20
+ window .getSelection ()! .removeAllRanges ()
21
+
22
+ const leftElements = document .querySelectorAll (' .file-diff-split .split-side-left' )!
23
+ const rightElements = document .querySelectorAll (' .file-diff-split .split-side-right' )!
24
+
25
+ for (const el of rightElements )
26
+ el .classList .toggle (' no-select' , side === ' left' )
27
+
28
+ for (const el of leftElements )
29
+ el .classList .toggle (' no-select' , side === ' right' )
30
+ }
18
31
</script >
19
32
20
33
<template >
@@ -27,31 +40,40 @@ function getCodeMarker(type: DiffType) {
27
40
</td >
28
41
</tr >
29
42
<tr v-else-if =" !splitLine.hide" >
30
- <template v-for =" line in [splitLine .left , splitLine .right ]" >
43
+ <template v-for =" ( line , index ) in [splitLine .left , splitLine .right ]" >
31
44
<!-- eslint-disable -->
32
45
<template v-if =" line .type === DiffType .EMPTY " >
33
46
<td class =" blob-num blob-num-empty empty-cell" />
34
47
<td class =" blob-code blob-code-empty empty-cell" />
35
48
</template >
36
49
<template v-else >
37
- <td class =" blob-num" :class =" {
38
- 'blob-num-deletion': line.type === DiffType.DELETE,
39
- 'blob-num-addition': line.type === DiffType.ADD,
40
- 'blob-num-context': line.type === DiffType.EQUAL,
41
- 'blob-num-hunk': splitLine.hide !== undefined,
42
-
43
- }" >
50
+ <td
51
+ class =" blob-num"
52
+ :class =" {
53
+ 'blob-num-deletion': line.type === DiffType.DELETE,
54
+ 'blob-num-addition': line.type === DiffType.ADD,
55
+ 'blob-num-context': line.type === DiffType.EQUAL,
56
+ 'blob-num-hunk': splitLine.hide !== undefined,
57
+ }"
58
+ >
44
59
{{ line.num }}
45
60
</td >
46
- <td class =" blob-code" :class =" {
47
- 'blob-code-deletion': line.type === DiffType.DELETE,
48
- 'blob-code-addition': line.type === DiffType.ADD,
49
- 'blob-code-context': line.type === DiffType.EQUAL,
50
- 'blob-code-hunk': splitLine.hide !== undefined,
51
-
52
- }" >
53
- <span class =" blob-code-inner blob-code-marker" :data-code-marker =" getCodeMarker(line.type)"
54
- v-html =" line.code" />
61
+ <td
62
+ class =" blob-code"
63
+ :class =" {
64
+ 'blob-code-deletion': line.type === DiffType.DELETE,
65
+ 'blob-code-addition': line.type === DiffType.ADD,
66
+ 'blob-code-context': line.type === DiffType.EQUAL,
67
+ 'blob-code-hunk': splitLine.hide !== undefined,
68
+ 'split-side-left': index === 0,
69
+ 'split-side-right': index === 1,
70
+ }"
71
+ @mousedown =" onSplitLineMousedown(index === 0 ? 'left' : 'right')"
72
+ >
73
+ <span
74
+ class =" blob-code-inner blob-code-marker" :data-code-marker =" getCodeMarker(line.type)"
75
+ v-html =" line.code"
76
+ />
55
77
</td >
56
78
</template >
57
79
<!-- eslint-enable -->
0 commit comments