Save directories per remoteAuthority

Part of #143318
This commit is contained in:
Daniel Imms 2022-02-18 04:12:39 -08:00
parent 9daf7d5fb9
commit 0941c02227
2 changed files with 7 additions and 7 deletions

View file

@ -404,7 +404,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._cwd = e;
this._xtermOnKey?.dispose();
this.refreshTabLabels(this.title, TitleEventSource.Config);
this._instantiationService.invokeFunction(getDirectoryHistory)?.add(e, null);
this._instantiationService.invokeFunction(getDirectoryHistory)?.add(e, { remoteAuthority: this.remoteAuthority });
});
} else if (e === TerminalCapability.CommandDetection) {
this.capabilities.get(TerminalCapability.CommandDetection)?.onCommandFinished(e => {
@ -855,9 +855,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// Gather previous session history
const history = this._instantiationService.invokeFunction(getDirectoryHistory);
const previousSessionItems: IQuickPickItem[] = [];
// Only add previous session item if it's not in this session
for (const [label] of history.entries) {
if (!cwds.includes(label)) {
// Only add previous session item if it's not in this session and it matches the remote authority
for (const [label, info] of history.entries) {
if ((info === null || info.remoteAuthority === this.remoteAuthority) && !cwds.includes(label)) {
previousSessionItems.push({
label,
buttons: [removeFromCommandHistoryButton]

View file

@ -53,10 +53,10 @@ export function getCommandHistory(accessor: ServicesAccessor): ITerminalPersiste
return commandHistory;
}
let directoryHistory: ITerminalPersistedHistory<null> | undefined = undefined;
export function getDirectoryHistory(accessor: ServicesAccessor): ITerminalPersistedHistory<null> {
let directoryHistory: ITerminalPersistedHistory<{ remoteAuthority?: string }> | undefined = undefined;
export function getDirectoryHistory(accessor: ServicesAccessor): ITerminalPersistedHistory<{ remoteAuthority?: string }> {
if (!directoryHistory) {
directoryHistory = accessor.get(IInstantiationService).createInstance(TerminalPersistedHistory, 'dirs') as TerminalPersistedHistory<null>;
directoryHistory = accessor.get(IInstantiationService).createInstance(TerminalPersistedHistory, 'dirs') as TerminalPersistedHistory<{ remoteAuthority?: string }>;
}
return directoryHistory;
}