@@ -6,7 +6,7 @@ import * as React from 'react';
6
6
import { IDiffProps } from './Diff' ;
7
7
import { httpGitRequest } from '../../git' ;
8
8
import { mergeView } from './mergeview' ;
9
- import { getRefValue , IDiffContext } from './model' ;
9
+ import { getRefValue , IDiffContext , IGitRef , ISpecialRef } from './model' ;
10
10
11
11
interface ICurrentReference {
12
12
special ?: 'WORKING' | 'INDEX' ;
@@ -35,7 +35,7 @@ export class PlainTextDiff extends React.Component<
35
35
}
36
36
37
37
componentDidMount ( ) {
38
- this . performDiff ( this . props . diffContext ) ;
38
+ this . _performDiff ( this . props . diffContext ) ;
39
39
}
40
40
41
41
render ( ) {
@@ -55,9 +55,10 @@ export class PlainTextDiff extends React.Component<
55
55
< div className = "jp-git-diff-Widget" >
56
56
< div className = "jp-git-diff-root" >
57
57
< div
58
- id = { `diffviewer-${ this . props . path } -${ getRefValue (
58
+ id = { this . _generateID (
59
+ this . props . path ,
59
60
this . props . diffContext . currentRef
60
- ) } ` }
61
+ ) }
61
62
className = "jp-git-PlainText-diff"
62
63
/>
63
64
</ div >
@@ -71,7 +72,7 @@ export class PlainTextDiff extends React.Component<
71
72
* to
72
73
* @param diffContext the context in which to perform the diff
73
74
*/
74
- private performDiff ( diffContext : IDiffContext ) : void {
75
+ private _performDiff ( diffContext : IDiffContext ) : void {
75
76
try {
76
77
// Resolve what API parameter to call.
77
78
let currentRefValue : ICurrentReference ;
@@ -119,6 +120,12 @@ export class PlainTextDiff extends React.Component<
119
120
}
120
121
}
121
122
123
+ private _generateID ( path : string , currentRef : IGitRef | ISpecialRef ) : string {
124
+ return `diffviewer-${ this . props . path . replace ( '/' , '-' ) } -${ getRefValue (
125
+ this . props . diffContext . currentRef
126
+ ) } `;
127
+ }
128
+
122
129
/**
123
130
* Creates and adds a diff viewer to the DOM with given content
124
131
*
@@ -130,9 +137,7 @@ export class PlainTextDiff extends React.Component<
130
137
131
138
mergeView (
132
139
document . getElementById (
133
- `diffviewer-${ this . props . path . replace ( '/' , '-' ) } -${ getRefValue (
134
- this . props . diffContext . currentRef
135
- ) } `
140
+ this . _generateID ( this . props . path , this . props . diffContext . currentRef )
136
141
) ,
137
142
{
138
143
value : currContent ,
0 commit comments