未验证 提交 5d73637a 编写于 作者: M Megan Rogge 提交者: GitHub

saves SCM widget input on window reload (#107261)

* saving SCM widget input

* Use a better key
Co-authored-by: NJoão Moreno <joao.moreno@microsoft.com>
Co-authored-by: NJoão Moreno <joao.moreno@microsoft.com>
上级 f1e631ab
......@@ -303,6 +303,10 @@ export class MainThreadSCM implements MainThreadSCMShape {
setTimeout(() => this._proxy.$setSelectedSourceControl(handle), 0);
}
if (repository.input.value) {
setTimeout(() => this._proxy.$onInputBoxValueChange(handle, repository.input.value), 0);
}
this._repositoryDisposables.set(handle, disposable);
}
......
......@@ -1311,7 +1311,7 @@ class SCMInputWidget extends Disposable {
if (value === textModel.getValue()) { // circuit breaker
return;
}
textModel.setValue(value);
textModel.setValue(input.value);
this.inputEditor.setPosition(textModel.getFullModelRange().getEndPosition());
}));
......@@ -1381,7 +1381,7 @@ class SCMInputWidget extends Disposable {
@IKeybindingService private keybindingService: IKeybindingService,
@IConfigurationService private configurationService: IConfigurationService,
@IInstantiationService instantiationService: IInstantiationService,
@IContextViewService private readonly contextViewService: IContextViewService,
@IContextViewService private readonly contextViewService: IContextViewService
) {
super();
......
......@@ -8,12 +8,20 @@ import { Event, Emitter } from 'vs/base/common/event';
import { ISCMService, ISCMProvider, ISCMInput, ISCMRepository, IInputValidator } from './scm';
import { ILogService } from 'vs/platform/log/common/log';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
class SCMInput implements ISCMInput {
private _value = '';
get value(): string {
if (this.root) {
const key = `scm/input:${this.repository.provider.label}:${this.root.path}`;
let storedValue = this.storageService.get(key, StorageScope.WORKSPACE);
if (storedValue) {
return storedValue;
}
}
return this._value;
}
......@@ -21,11 +29,14 @@ class SCMInput implements ISCMInput {
if (value === this._value) {
return;
}
this._value = value;
if (this.root) {
const key = `scm/input:${this.repository.provider.label}:${this.root.path}`;
this.storageService.store(key, value, StorageScope.WORKSPACE);
}
this._onDidChange.fire(value);
}
private root;
private readonly _onDidChange = new Emitter<string>();
readonly onDidChange: Event<string> = this._onDidChange.event;
......@@ -55,7 +66,8 @@ class SCMInput implements ISCMInput {
}
private readonly _onDidChangeVisibility = new Emitter<boolean>();
readonly onDidChangeVisibility: Event<boolean> = this._onDidChangeVisibility.event;
readonly onDidChangeVisibility: Event<boolean> = this._onDidChangeVisibility
.event;
private _validateInput: IInputValidator = () => Promise.resolve(undefined);
......@@ -71,7 +83,13 @@ class SCMInput implements ISCMInput {
private readonly _onDidChangeValidateInput = new Emitter<void>();
readonly onDidChangeValidateInput: Event<void> = this._onDidChangeValidateInput.event;
constructor(readonly repository: ISCMRepository) { }
constructor(
readonly repository: ISCMRepository,
@IStorageService private storageService: IStorageService
) {
this.root = this.repository.provider.rootUri;
this._value = this.value;
}
}
class SCMRepository implements ISCMRepository {
......@@ -84,11 +102,12 @@ class SCMRepository implements ISCMRepository {
private readonly _onDidChangeSelection = new Emitter<boolean>();
readonly onDidChangeSelection: Event<boolean> = this._onDidChangeSelection.event;
readonly input: ISCMInput = new SCMInput(this);
readonly input: ISCMInput = new SCMInput(this, this.storageService);
constructor(
public readonly provider: ISCMProvider,
private disposable: IDisposable
private disposable: IDisposable,
@IStorageService private storageService: IStorageService
) { }
setSelected(selected: boolean): void {
......@@ -128,7 +147,8 @@ export class SCMService implements ISCMService {
constructor(
@ILogService private readonly logService: ILogService,
@IContextKeyService contextKeyService: IContextKeyService
@IContextKeyService contextKeyService: IContextKeyService,
@IStorageService private storageService: IStorageService
) {
this.providerCount = contextKeyService.createKey('scm.providerCount', 0);
}
......@@ -161,7 +181,7 @@ export class SCMService implements ISCMService {
this.providerCount.set(this._repositories.length);
});
const repository = new SCMRepository(provider, disposable);
const repository = new SCMRepository(provider, disposable, this.storageService);
const selectedDisposable = Event.map(Event.filter(repository.onDidChangeSelection, selected => selected), _ => repository)(this.select, this);
this._repositories.push(repository);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册