refactor: write lastVisited and query at the same time

In addition, the `settings.write` method now uses shallow merge by default
This commit is contained in:
futengda
2020-07-31 11:39:37 +08:00
parent b6e791f7d0
commit ecb9bb2428
2 changed files with 5 additions and 10 deletions

View File

@@ -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) {