@@ -28,6 +28,7 @@ import { derivedObservableWithCache, latestChangedValue, observableFromEventOpts
28
28
import { Command } from 'vs/editor/common/languages' ;
29
29
import { ISCMHistoryItemGroup } from 'vs/workbench/contrib/scm/common/history' ;
30
30
import { ILogService } from 'vs/platform/log/common/log' ;
31
+ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
31
32
32
33
export class SCMActiveRepositoryController extends Disposable implements IWorkbenchContribution {
33
34
private readonly _countBadgeConfig = observableConfigValue < 'all' | 'focused' | 'off' > ( 'scm.countBadge' , 'all' , this . configurationService ) ;
@@ -49,18 +50,28 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
49
50
private readonly _activeEditorRepository = derivedObservableWithCache < ISCMRepository | undefined > ( this , ( reader , lastValue ) => {
50
51
const activeResource = EditorResourceAccessor . getOriginalUri ( this . _activeEditor . read ( reader ) ) ;
51
52
if ( ! activeResource ) {
53
+ if ( this . environmentService . enableSmokeTestDriver ) {
54
+ this . logService . info ( 'SCMActiveRepositoryController (activeEditorRepository derived): no activeResource' ) ;
55
+ }
52
56
return lastValue ;
53
57
}
54
58
55
59
const repository = this . scmService . getRepository ( activeResource ) ;
56
60
if ( ! repository ) {
61
+ if ( this . environmentService . enableSmokeTestDriver ) {
62
+ this . logService . info ( `SCMActiveRepositoryController (activeEditorRepository derived): no repository for '${ activeResource . toString ( ) } '` ) ;
63
+ }
57
64
return lastValue ;
58
65
}
59
66
60
67
return Object . create ( repository ) ;
61
68
} ) ;
62
69
63
- private readonly _activeRepository = latestChangedValue ( this . _focusedRepository , this . _activeEditorRepository ) ;
70
+ /**
71
+ * The focused repository takes precedence over the active editor repository when the observable
72
+ * values are updated in the same transaction (or during the initial read of the observable value).
73
+ */
74
+ private readonly _activeRepository = latestChangedValue ( this . _activeEditorRepository , this . _focusedRepository ) ;
64
75
65
76
private readonly _countBadgeRepositories = derived ( reader => {
66
77
switch ( this . _countBadgeConfig . read ( reader ) ) {
@@ -104,7 +115,8 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
104
115
@ISCMService private readonly scmService : ISCMService ,
105
116
@ISCMViewService private readonly scmViewService : ISCMViewService ,
106
117
@IStatusbarService private readonly statusbarService : IStatusbarService ,
107
- @ITitleService private readonly titleService : ITitleService
118
+ @ITitleService private readonly titleService : ITitleService ,
119
+ @IWorkbenchEnvironmentService private readonly environmentService : IWorkbenchEnvironmentService
108
120
) {
109
121
super ( ) ;
110
122
@@ -116,30 +128,38 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
116
128
{ name : 'activeRepositoryBranchName' , contextKey : ActiveRepositoryContextKeys . ActiveRepositoryBranchName . key , }
117
129
] ) ;
118
130
119
- this . _register ( autorunWithStore ( ( reader , store ) => {
120
- this . _updateActivityCountBadge ( this . _countBadge . read ( reader ) , store ) ;
121
- } ) ) ;
131
+ if ( this . environmentService . enableSmokeTestDriver ) {
132
+ this . _register ( autorun ( reader => {
133
+ const repository = this . _focusedRepository . read ( reader ) ;
134
+ const commands = repository ?. provider . statusBarCommands . read ( reader ) ;
122
135
123
- this . _register ( autorun ( reader => {
124
- const repository = this . _focusedRepository . read ( reader ) ;
125
- const commands = repository ?. provider . statusBarCommands . read ( reader ) ?? [ ] ;
136
+ this . logService . info ( 'SCMActiveRepositoryController (focusedRepository):' , repository ?. id ?? 'no id' ) ;
137
+ this . logService . info ( 'SCMActiveRepositoryController (focusedRepository):' , commands ? commands . map ( c => c . title ) . join ( ', ' ) : 'no commands' ) ;
138
+ } ) ) ;
126
139
127
- this . logService . info ( 'SCMActiveRepositoryController (focusedRepository):' , commands . map ( c => c . title ) . join ( ', ' ) ) ;
128
- } ) ) ;
140
+ this . _register ( autorun ( reader => {
141
+ const repository = this . _activeEditorRepository . read ( reader ) ;
142
+ const commands = repository ?. provider . statusBarCommands . read ( reader ) ;
129
143
130
- this . _register ( autorun ( reader => {
131
- const repository = this . _activeEditorRepository . read ( reader ) ;
132
- const commands = repository ?. provider . statusBarCommands . read ( reader ) ?? [ ] ;
144
+ this . logService . info ( 'SCMActiveRepositoryController (activeEditorRepository):' , repository ?. id ?? 'no id' ) ;
145
+ this . logService . info ( 'SCMActiveRepositoryController (activeEditorRepository):' , commands ? commands . map ( c => c . title ) . join ( ', ' ) : 'no commands' ) ;
146
+ } ) ) ;
147
+ }
133
148
134
- this . logService . info ( 'SCMActiveRepositoryController (activeEditorRepository):' , commands . map ( c => c . title ) . join ( ', ' ) ) ;
149
+ this . _register ( autorunWithStore ( ( reader , store ) => {
150
+ this . _updateActivityCountBadge ( this . _countBadge . read ( reader ) , store ) ;
135
151
} ) ) ;
136
152
137
153
this . _register ( autorunWithStore ( ( reader , store ) => {
138
154
const repository = this . _activeRepository . read ( reader ) ;
139
- const commands = repository ?. provider . statusBarCommands . read ( reader ) ?? [ ] ;
140
- this . logService . info ( 'SCMActiveRepositoryController (status bar):' , commands . map ( c => c . title ) . join ( ', ' ) ) ;
155
+ const commands = repository ?. provider . statusBarCommands . read ( reader ) ;
141
156
142
- this . _updateStatusBar ( repository , commands , store ) ;
157
+ if ( this . environmentService . enableSmokeTestDriver ) {
158
+ this . logService . info ( 'SCMActiveRepositoryController (status bar):' , repository ?. id ?? 'no id' ) ;
159
+ this . logService . info ( 'SCMActiveRepositoryController (status bar):' , commands ? commands . map ( c => c . title ) . join ( ', ' ) : 'no commands' ) ;
160
+ }
161
+
162
+ this . _updateStatusBar ( repository , commands ?? [ ] , store ) ;
143
163
} ) ) ;
144
164
145
165
this . _register ( autorun ( reader => {
@@ -165,7 +185,9 @@ export class SCMActiveRepositoryController extends Disposable implements IWorkbe
165
185
166
186
private _updateStatusBar ( repository : ISCMRepository | undefined , commands : readonly Command [ ] , store : DisposableStore ) : void {
167
187
if ( ! repository ) {
168
- this . logService . info ( 'SCMActiveRepositoryController (status bar): repository is undefined' ) ;
188
+ if ( this . environmentService . enableSmokeTestDriver ) {
189
+ this . logService . info ( 'SCMActiveRepositoryController (status bar): repository is undefined' ) ;
190
+ }
169
191
return ;
170
192
}
171
193
0 commit comments