@@ -19,10 +19,10 @@ import { ShowQuickCommitCommand } from '../commands';
1919import { configuration } from '../configuration' ;
2020import { BuiltInCommands } from '../constants' ;
2121import { Container } from '../container' ;
22- import { Repository , RepositoryChange , RepositoryChangeComparisonMode } from '../git/git' ;
22+ import { RepositoryChange , RepositoryChangeComparisonMode } from '../git/git' ;
2323import { Logger } from '../logger' ;
2424import { Messages } from '../messages' ;
25- import { debug , gate , Iterables } from '../system' ;
25+ import { debug , gate , Iterables , Strings } from '../system' ;
2626import {
2727 Author ,
2828 Commit ,
@@ -86,7 +86,7 @@ interface RebaseEditorContext {
8686 readonly id : number ;
8787 readonly document : TextDocument ;
8888 readonly panel : WebviewPanel ;
89- readonly repo : Repository ;
89+ readonly repoPath : string ;
9090 readonly subscriptions : Disposable [ ] ;
9191
9292 abortOnClose : boolean ;
@@ -172,7 +172,8 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
172172
173173 @debug < RebaseEditorProvider [ 'resolveCustomTextEditor' ] > ( { args : false } )
174174 async resolveCustomTextEditor ( document : TextDocument , panel : WebviewPanel , _token : CancellationToken ) {
175- const repo = await this . getRepository ( document ) ;
175+ const repoPath = Strings . normalizePath ( Uri . joinPath ( document . uri , '..' , '..' , '..' ) . fsPath ) ;
176+ const repo = await Container . git . getRepository ( repoPath ) ;
176177
177178 const subscriptions : Disposable [ ] = [ ] ;
178179 const context : RebaseEditorContext = {
@@ -182,7 +183,7 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
182183 subscriptions : subscriptions ,
183184 document : document ,
184185 panel : panel ,
185- repo : repo ,
186+ repoPath : repo ?. path ?? repoPath ,
186187 abortOnClose : true ,
187188 } ;
188189
@@ -208,15 +209,20 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
208209 workspace . onDidSaveTextDocument ( e => {
209210 if ( e . uri . toString ( ) !== document . uri . toString ( ) ) return ;
210211
211- void this . getStateAndNotify ( context ) ;
212- } ) ,
213- repo . onDidChange ( e => {
214- if ( ! e . changed ( RepositoryChange . Rebase , RepositoryChangeComparisonMode . Any ) ) return ;
215-
216212 void this . getStateAndNotify ( context ) ;
217213 } ) ,
218214 ) ;
219215
216+ if ( repo != null ) {
217+ subscriptions . push (
218+ repo . onDidChange ( e => {
219+ if ( ! e . changed ( RepositoryChange . Rebase , RepositoryChangeComparisonMode . Any ) ) return ;
220+
221+ void this . getStateAndNotify ( context ) ;
222+ } ) ,
223+ ) ;
224+ }
225+
220226 panel . webview . options = { enableCommandUris : true , enableScripts : true } ;
221227 panel . webview . html = await this . getHtml ( context ) ;
222228
@@ -243,8 +249,8 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
243249 }
244250
245251 private async parseState ( context : RebaseEditorContext ) : Promise < RebaseState > {
246- const branch = await context . repo . getBranch ( ) ;
247- const state = await parseRebaseTodo ( context . document . getText ( ) , context . repo , branch ?. name ) ;
252+ const branch = await Container . git . getBranch ( context . repoPath ) ;
253+ const state = await parseRebaseTodo ( context . document . getText ( ) , context . repoPath , branch ?. name ) ;
248254 return state ;
249255 }
250256
@@ -493,20 +499,11 @@ export class RebaseEditorProvider implements CustomTextEditorProvider, Disposabl
493499
494500 return html ;
495501 }
496-
497- private async getRepository ( document : TextDocument ) : Promise < Repository > {
498- const repo = await Container . git . getRepository ( Uri . joinPath ( document . uri , '..' , '..' , '..' ) ) ;
499- if ( repo == null ) {
500- // eslint-disable-next-line no-debugger
501- debugger ;
502- }
503- return repo ! ;
504- }
505502}
506503
507504async function parseRebaseTodo (
508505 contents : string | { entries : RebaseEntry [ ] ; onto : string } ,
509- repo : Repository ,
506+ repoPath : string ,
510507 branch : string | undefined ,
511508) : Promise < Omit < RebaseState , 'rebasing' > > {
512509 let onto : string ;
@@ -521,7 +518,7 @@ async function parseRebaseTodo(
521518 const authors = new Map < string , Author > ( ) ;
522519 const commits : Commit [ ] = [ ] ;
523520
524- const log = await repo . searchForCommits ( {
521+ const log = await Container . git . getLogForSearch ( repoPath , {
525522 pattern : `${ onto ? `#:${ onto } ` : '' } ${ Iterables . join (
526523 Iterables . map ( entries , e => `#:${ e . ref } ` ) ,
527524 ' ' ,
@@ -587,7 +584,7 @@ async function parseRebaseTodo(
587584 commits : commits ,
588585 commands : {
589586 // eslint-disable-next-line no-template-curly-in-string
590- commit : ShowQuickCommitCommand . getMarkdownCommandArgs ( '${commit}' , repo . path ) ,
587+ commit : ShowQuickCommitCommand . getMarkdownCommandArgs ( '${commit}' , repoPath ) ,
591588 } ,
592589 } ;
593590}
0 commit comments