Fix "can't read 'focus' of undefined' error when resizing settings editor while exclude 'add' input is visible

This commit is contained in:
Rob Lourens 2018-10-03 11:57:39 -07:00
parent 26365c8957
commit 40a80d0197
2 changed files with 15 additions and 4 deletions

View file

@ -305,6 +305,15 @@ export function timeout(millis: number, token?: CancellationToken): CancelablePr
});
}
export function disposableTimeout(handler: TimerHandler, timeout = 0): IDisposable {
const timer = setTimeout(handler, timeout);
return {
dispose() {
clearTimeout(timer);
}
};
}
/**
* Returns a new promise that joins the provided promise. Upon completion of
* the provided promise the provided function will always be called. This

View file

@ -19,6 +19,7 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
import { foreground, inputBackground, inputBorder, inputForeground, listActiveSelectionBackground, listActiveSelectionForeground, listHoverBackground, listHoverForeground, listInactiveSelectionBackground, listInactiveSelectionForeground, registerColor, selectBackground, selectBorder, selectForeground, textLinkForeground, textPreformatForeground, editorWidgetBorder } from 'vs/platform/theme/common/colorRegistry';
import { attachButtonStyler, attachInputBoxStyler } from 'vs/platform/theme/common/styler';
import { ICssStyleCollector, ITheme, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { disposableTimeout } from 'vs/base/common/async';
const $ = DOM.$;
export const settingsHeaderForeground = registerColor('settings.headerForeground', { light: '#444444', dark: '#e7e7e7', hc: '#ffffff' }, localize('headerForeground', "(For settings editor preview) The foreground color for a section header or active title."));
@ -457,10 +458,11 @@ export class ExcludeSettingWidget extends Disposable {
this.listDisposables.push(attachButtonStyler(cancelButton, this.themeService));
this.listDisposables.push(cancelButton.onDidClick(() => onSubmit(false)));
setTimeout(() => {
patternInput.focus();
patternInput.select();
}, 0);
this.listDisposables.push(
disposableTimeout(() => {
patternInput.focus();
patternInput.select();
}));
return rowElement;
}