src/vs/workbench/services/dialogs/browser/simpleFileDialog.ts/SimpleFileDialog/updateItems
class SimpleFileDialog:	private async updateItems(newFolder: URI, force: boolean = false, trailing?: string): Promise<boolean> {
		this.busy = true;
		this.autoCompletePathSegment = '';
		const isSave = !!trailing;
		let result = false;

		const updatingPromise = createCancelablePromise(async token => {
			let folderStat: IFileStat | undefined;
			try {
				folderStat = await this.fileService.resolve(newFolder);
				if (!folderStat.isDirectory) {
					trailing = resources.basename(newFolder);
					newFolder = resources.dirname(newFolder);
					folderStat = undefined;
					result = true;
				}
			} catch (e) {
				// The file/directory doesn't exist
			}
			const newValue = trailing ? this.pathAppend(newFolder, trailing) : this.pathFromUri(newFolder, true);
			this.currentFolder = resources.addTrailingPathSeparator(newFolder, this.separator);
			this.userEnteredPathSegment = trailing ? trailing : '';

			return this.createItems(folderStat, this.currentFolder, token).then(items => {
				if (token.isCancellationRequested) {
					this.busy = false;
					return false;
				}

				this.filePickBox.items = items;
				this.filePickBox.activeItems = [<FileQuickPickItem>this.filePickBox.items[0]];
				this.filePickBox.activeItems = [];

				// the user might have continued typing while we were updating. Only update the input box if it doesn't match the directory.
				if (!equalsIgnoreCase(this.filePickBox.value, newValue) && force) {
					this.filePickBox.valueSelection = [0, this.filePickBox.value.length];
					this.insertText(newValue, newValue);
				}
				if (force && trailing && isSave) {
					// Keep the cursor position in front of the save as name.
					this.filePickBox.valueSelection = [this.filePickBox.value.length - trailing.length, this.filePickBox.value.length - trailing.length];
				} else if (!trailing) {
					// If there is trailing, we don't move the cursor. If there is no trailing, cursor goes at the end.
					this.filePickBox.valueSelection = [this.filePickBox.value.length, this.filePickBox.value.length];
				}
				this.busy = false;
				this.updatingPromise = undefined;
				return result;
			});
		});

		if (this.updatingPromise !== undefined) {
			this.updatingPromise.cancel();
		}
		this.updatingPromise = updatingPromise;

		return updatingPromise;
	}