33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
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' ;
77import { Model } from './model' ;
88import { dispose , fromNow , IDisposable } from './util' ;
99import { Repository } from './repository' ;
1010import { throttle } from './decorators' ;
1111import { BlameInformation } from './git' ;
1212import { fromGitUri , isGitUri } from './uri' ;
1313import { emojify , ensureEmojis } from './emoji' ;
14+ import { getWorkingTreeAndIndexDiffInformation , getWorkingTreeDiffInformation } from './staging' ;
1415
1516function lineRangesContainLine ( changes : readonly TextEditorChange [ ] , lineNumber : number ) : boolean {
1617 return changes . some ( c => c . modified . startLineNumber <= lineNumber && lineNumber < c . modified . endLineNumberExclusive ) ;
@@ -277,10 +278,6 @@ export class GitBlameController {
277278 return blameInformation ;
278279 }
279280
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-
284281 @throttle
285282 private async _updateTextEditorBlameInformation ( textEditor : TextEditor | undefined , showBlameInformationForPositionZero = false ) : Promise < void > {
286283 if ( ! textEditor ?. diffInformation || textEditor !== window . activeTextEditor ) {
@@ -319,7 +316,7 @@ export class GitBlameController {
319316 workingTreeAndIndexChanges = undefined ;
320317 } else if ( ref === '' ) {
321318 // 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 ) ;
323320
324321 // Working tree + index diff information is present and it is stale
325322 if ( diffInformationWorkingTreeAndIndex && diffInformationWorkingTreeAndIndex . isStale ) {
@@ -333,15 +330,15 @@ export class GitBlameController {
333330 }
334331 } else {
335332 // Working tree diff information. Diff Editor (Working Tree) -> Text Editor
336- const diffInformationWorkingTree = this . _findDiffInformation ( textEditor , '~' ) ?? this . _findDiffInformation ( textEditor , '' ) ;
333+ const diffInformationWorkingTree = getWorkingTreeDiffInformation ( textEditor ) ;
337334
338335 // Working tree diff information is not present or it is stale
339336 if ( ! diffInformationWorkingTree || diffInformationWorkingTree . isStale ) {
340337 return ;
341338 }
342339
343340 // Working tree + index diff information
344- const diffInformationWorkingTreeAndIndex = this . _findDiffInformation ( textEditor , 'HEAD' ) ;
341+ const diffInformationWorkingTreeAndIndex = getWorkingTreeAndIndexDiffInformation ( textEditor ) ;
345342
346343 // Working tree + index diff information is present and it is stale
347344 if ( diffInformationWorkingTreeAndIndex && diffInformationWorkingTreeAndIndex . isStale ) {
0 commit comments