3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { DecorationOptions , l10n , Position , Range , TextEditor , TextEditorChange , TextEditorDecorationType , TextEditorChangeKind , ThemeColor , Uri , window , workspace , EventEmitter , ConfigurationChangeEvent , StatusBarItem , StatusBarAlignment , Command , MarkdownString , TextEditorDiffInformation } from 'vscode' ;
6
+ import { DecorationOptions , l10n , Position , Range , TextEditor , TextEditorChange , TextEditorDecorationType , TextEditorChangeKind , ThemeColor , Uri , window , workspace , EventEmitter , ConfigurationChangeEvent , StatusBarItem , StatusBarAlignment , Command , MarkdownString } from 'vscode' ;
7
7
import { Model } from './model' ;
8
8
import { dispose , fromNow , IDisposable } from './util' ;
9
9
import { Repository } from './repository' ;
10
10
import { throttle } from './decorators' ;
11
11
import { BlameInformation } from './git' ;
12
12
import { fromGitUri , isGitUri } from './uri' ;
13
13
import { emojify , ensureEmojis } from './emoji' ;
14
+ import { getWorkingTreeAndIndexDiffInformation , getWorkingTreeDiffInformation } from './staging' ;
14
15
15
16
function lineRangesContainLine ( changes : readonly TextEditorChange [ ] , lineNumber : number ) : boolean {
16
17
return changes . some ( c => c . modified . startLineNumber <= lineNumber && lineNumber < c . modified . endLineNumberExclusive ) ;
@@ -277,10 +278,6 @@ export class GitBlameController {
277
278
return blameInformation ;
278
279
}
279
280
280
- private _findDiffInformation ( textEditor : TextEditor , ref : string ) : TextEditorDiffInformation | undefined {
281
- return textEditor . diffInformation ?. find ( diff => diff . original && isGitUri ( diff . original ) && fromGitUri ( diff . original ) . ref === ref ) ;
282
- }
283
-
284
281
@throttle
285
282
private async _updateTextEditorBlameInformation ( textEditor : TextEditor | undefined , showBlameInformationForPositionZero = false ) : Promise < void > {
286
283
if ( ! textEditor ?. diffInformation || textEditor !== window . activeTextEditor ) {
@@ -319,7 +316,7 @@ export class GitBlameController {
319
316
workingTreeAndIndexChanges = undefined ;
320
317
} else if ( ref === '' ) {
321
318
// Resource on the right-hand side of the diff editor when viewing a resource from the index.
322
- const diffInformationWorkingTreeAndIndex = this . _findDiffInformation ( textEditor , 'HEAD' ) ;
319
+ const diffInformationWorkingTreeAndIndex = getWorkingTreeAndIndexDiffInformation ( textEditor ) ;
323
320
324
321
// Working tree + index diff information is present and it is stale
325
322
if ( diffInformationWorkingTreeAndIndex && diffInformationWorkingTreeAndIndex . isStale ) {
@@ -333,15 +330,15 @@ export class GitBlameController {
333
330
}
334
331
} else {
335
332
// Working tree diff information. Diff Editor (Working Tree) -> Text Editor
336
- const diffInformationWorkingTree = this . _findDiffInformation ( textEditor , '~' ) ?? this . _findDiffInformation ( textEditor , '' ) ;
333
+ const diffInformationWorkingTree = getWorkingTreeDiffInformation ( textEditor ) ;
337
334
338
335
// Working tree diff information is not present or it is stale
339
336
if ( ! diffInformationWorkingTree || diffInformationWorkingTree . isStale ) {
340
337
return ;
341
338
}
342
339
343
340
// Working tree + index diff information
344
- const diffInformationWorkingTreeAndIndex = this . _findDiffInformation ( textEditor , 'HEAD' ) ;
341
+ const diffInformationWorkingTreeAndIndex = getWorkingTreeAndIndexDiffInformation ( textEditor ) ;
345
342
346
343
// Working tree + index diff information is present and it is stale
347
344
if ( diffInformationWorkingTreeAndIndex && diffInformationWorkingTreeAndIndex . isStale ) {
0 commit comments