diff --git a/src/node/app/vscode.ts b/src/node/app/vscode.ts index a41212ca..8965fb6f 100644 --- a/src/node/app/vscode.ts +++ b/src/node/app/vscode.ts @@ -183,14 +183,9 @@ export class VscodeHttpProvider extends HttpProvider { }), ]) - let promise = Promise.resolve() - if (startPath) { - promise = settings.write({ lastVisited: startPath }) - } - // `settings.write` depends on `settings.read` internally. To avoid race conditions, a promise is added here to synchronize. - promise.then(() => { - // the query should not be extends, but should be replaced directly. - settings.write({ query: route.query }, true) + settings.write({ + lastVisited: startPath || lastVisited, // If startpath is undefined, then fallback to lastVisited + query: route.query, }) if (!this.isDev) { diff --git a/src/node/settings.ts b/src/node/settings.ts index abb8f63b..7564b531 100644 --- a/src/node/settings.ts +++ b/src/node/settings.ts @@ -30,9 +30,9 @@ export class SettingsProvider { /** * Write settings combined with current settings. On failure log a warning. - * Objects will be merged and everything else will be replaced. + * Settings can be shallow or deep merged. */ - public async write(settings: Partial, shallow?: boolean): Promise { + public async write(settings: Partial, shallow = true): Promise { try { const oldSettings = await this.read() const nextSettings = shallow ? Object.assign({}, oldSettings, settings) : extend(oldSettings, settings)