@@ -15,6 +15,19 @@ function getCodeMarker(type: DiffType) {
1515 return ' +'
1616 return ' '
1717}
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+ }
1831 </script >
1932
2033<template >
@@ -27,31 +40,40 @@ function getCodeMarker(type: DiffType) {
2740 </td >
2841 </tr >
2942 <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 ]" >
3144 <!-- eslint-disable -->
3245 <template v-if =" line .type === DiffType .EMPTY " >
3346 <td class =" blob-num blob-num-empty empty-cell" />
3447 <td class =" blob-code blob-code-empty empty-cell" />
3548 </template >
3649 <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+ >
4459 {{ line.num }}
4560 </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+ />
5577 </td >
5678 </template >
5779 <!-- eslint-enable -->
0 commit comments