@@ -8,24 +8,35 @@ import { Event, Emitter } from 'vs/base/common/event';
88import { ISCMService , ISCMProvider , ISCMInput , ISCMRepository , IInputValidator } from './scm' ;
99import { ILogService } from 'vs/platform/log/common/log' ;
1010import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
11+ import { IStorageService , StorageScope } from 'vs/platform/storage/common/storage' ;
1112
1213class SCMInput implements ISCMInput {
1314
1415 private _value = '' ;
1516
1617 get value ( ) : string {
18+ if ( this . root ) {
19+ const key = `scm/input:${ this . repository . provider . label } :${ this . root . path } ` ;
20+ let storedValue = this . storageService . get ( key , StorageScope . WORKSPACE ) ;
21+ if ( storedValue ) {
22+ return storedValue ;
23+ }
24+ }
1725 return this . _value ;
1826 }
1927
2028 set value ( value : string ) {
2129 if ( value === this . _value ) {
2230 return ;
2331 }
24-
2532 this . _value = value ;
33+ if ( this . root ) {
34+ const key = `scm/input:${ this . repository . provider . label } :${ this . root . path } ` ;
35+ this . storageService . store ( key , value , StorageScope . WORKSPACE ) ;
36+ }
2637 this . _onDidChange . fire ( value ) ;
2738 }
28-
39+ private root ;
2940 private readonly _onDidChange = new Emitter < string > ( ) ;
3041 readonly onDidChange : Event < string > = this . _onDidChange . event ;
3142
@@ -55,7 +66,8 @@ class SCMInput implements ISCMInput {
5566 }
5667
5768 private readonly _onDidChangeVisibility = new Emitter < boolean > ( ) ;
58- readonly onDidChangeVisibility : Event < boolean > = this . _onDidChangeVisibility . event ;
69+ readonly onDidChangeVisibility : Event < boolean > = this . _onDidChangeVisibility
70+ . event ;
5971
6072 private _validateInput : IInputValidator = ( ) => Promise . resolve ( undefined ) ;
6173
@@ -71,7 +83,13 @@ class SCMInput implements ISCMInput {
7183 private readonly _onDidChangeValidateInput = new Emitter < void > ( ) ;
7284 readonly onDidChangeValidateInput : Event < void > = this . _onDidChangeValidateInput . event ;
7385
74- constructor ( readonly repository : ISCMRepository ) { }
86+ constructor (
87+ readonly repository : ISCMRepository ,
88+ @IStorageService private storageService : IStorageService
89+ ) {
90+ this . root = this . repository . provider . rootUri ;
91+ this . _value = this . value ;
92+ }
7593}
7694
7795class SCMRepository implements ISCMRepository {
@@ -84,11 +102,12 @@ class SCMRepository implements ISCMRepository {
84102 private readonly _onDidChangeSelection = new Emitter < boolean > ( ) ;
85103 readonly onDidChangeSelection : Event < boolean > = this . _onDidChangeSelection . event ;
86104
87- readonly input : ISCMInput = new SCMInput ( this ) ;
105+ readonly input : ISCMInput = new SCMInput ( this , this . storageService ) ;
88106
89107 constructor (
90108 public readonly provider : ISCMProvider ,
91- private disposable : IDisposable
109+ private disposable : IDisposable ,
110+ @IStorageService private storageService : IStorageService
92111 ) { }
93112
94113 setSelected ( selected : boolean ) : void {
@@ -128,7 +147,8 @@ export class SCMService implements ISCMService {
128147
129148 constructor (
130149 @ILogService private readonly logService : ILogService ,
131- @IContextKeyService contextKeyService : IContextKeyService
150+ @IContextKeyService contextKeyService : IContextKeyService ,
151+ @IStorageService private storageService : IStorageService
132152 ) {
133153 this . providerCount = contextKeyService . createKey ( 'scm.providerCount' , 0 ) ;
134154 }
@@ -161,7 +181,7 @@ export class SCMService implements ISCMService {
161181 this . providerCount . set ( this . _repositories . length ) ;
162182 } ) ;
163183
164- const repository = new SCMRepository ( provider , disposable ) ;
184+ const repository = new SCMRepository ( provider , disposable , this . storageService ) ;
165185 const selectedDisposable = Event . map ( Event . filter ( repository . onDidChangeSelection , selected => selected ) , _ => repository ) ( this . select , this ) ;
166186
167187 this . _repositories . push ( repository ) ;
0 commit comments