Skip to content

Commit 93cfe48

Browse files
committed
Strict property initialization (microsoft#78168)
1 parent 56c472e commit 93cfe48

7 files changed

Lines changed: 165 additions & 171 deletions

File tree

src/vs/base/browser/ui/findinput/replaceInput.ts

Lines changed: 86 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,96 @@ export class ReplaceInput extends Widget {
123123
this.inputValidationErrorBackground = options.inputValidationErrorBackground;
124124
this.inputValidationErrorForeground = options.inputValidationErrorForeground;
125125

126+
const history = options.history || [];
126127
const flexibleHeight = !!options.flexibleHeight;
127128
const flexibleWidth = !!options.flexibleWidth;
128129
const flexibleMaxHeight = options.flexibleMaxHeight;
129130

130-
this.buildDomNode(options.history || [], flexibleHeight, flexibleWidth, flexibleMaxHeight);
131+
this.domNode = document.createElement('div');
132+
dom.addClass(this.domNode, 'monaco-findInput');
133+
134+
this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
135+
ariaLabel: this.label || '',
136+
placeholder: this.placeholder || '',
137+
validationOptions: {
138+
validation: this.validation
139+
},
140+
inputBackground: this.inputBackground,
141+
inputForeground: this.inputForeground,
142+
inputBorder: this.inputBorder,
143+
inputValidationInfoBackground: this.inputValidationInfoBackground,
144+
inputValidationInfoForeground: this.inputValidationInfoForeground,
145+
inputValidationInfoBorder: this.inputValidationInfoBorder,
146+
inputValidationWarningBackground: this.inputValidationWarningBackground,
147+
inputValidationWarningForeground: this.inputValidationWarningForeground,
148+
inputValidationWarningBorder: this.inputValidationWarningBorder,
149+
inputValidationErrorBackground: this.inputValidationErrorBackground,
150+
inputValidationErrorForeground: this.inputValidationErrorForeground,
151+
inputValidationErrorBorder: this.inputValidationErrorBorder,
152+
history,
153+
flexibleHeight,
154+
flexibleWidth,
155+
flexibleMaxHeight
156+
}));
157+
158+
this.preserveCase = this._register(new PreserveCaseCheckbox({
159+
appendTitle: '',
160+
isChecked: false,
161+
inputActiveOptionBorder: this.inputActiveOptionBorder,
162+
inputActiveOptionBackground: this.inputActiveOptionBackground,
163+
}));
164+
this._register(this.preserveCase.onChange(viaKeyboard => {
165+
this._onDidOptionChange.fire(viaKeyboard);
166+
if (!viaKeyboard && this.fixFocusOnOptionClickEnabled) {
167+
this.inputBox.focus();
168+
}
169+
this.validate();
170+
}));
171+
this._register(this.preserveCase.onKeyDown(e => {
172+
this._onPreserveCaseKeyDown.fire(e);
173+
}));
174+
175+
if (this._showOptionButtons) {
176+
this.cachedOptionsWidth = this.preserveCase.width();
177+
} else {
178+
this.cachedOptionsWidth = 0;
179+
}
180+
181+
// Arrow-Key support to navigate between options
182+
let indexes = [this.preserveCase.domNode];
183+
this.onkeydown(this.domNode, (event: IKeyboardEvent) => {
184+
if (event.equals(KeyCode.LeftArrow) || event.equals(KeyCode.RightArrow) || event.equals(KeyCode.Escape)) {
185+
let index = indexes.indexOf(<HTMLElement>document.activeElement);
186+
if (index >= 0) {
187+
let newIndex: number = -1;
188+
if (event.equals(KeyCode.RightArrow)) {
189+
newIndex = (index + 1) % indexes.length;
190+
} else if (event.equals(KeyCode.LeftArrow)) {
191+
if (index === 0) {
192+
newIndex = indexes.length - 1;
193+
} else {
194+
newIndex = index - 1;
195+
}
196+
}
197+
198+
if (event.equals(KeyCode.Escape)) {
199+
indexes[index].blur();
200+
} else if (newIndex >= 0) {
201+
indexes[newIndex].focus();
202+
}
203+
204+
dom.EventHelper.stop(event, true);
205+
}
206+
}
207+
});
208+
209+
210+
let controls = document.createElement('div');
211+
controls.className = 'controls';
212+
controls.style.display = this._showOptionButtons ? 'block' : 'none';
213+
controls.appendChild(this.preserveCase.domNode);
214+
215+
this.domNode.appendChild(controls);
131216

132217
if (parent) {
133218
parent.appendChild(this.domNode);
@@ -256,94 +341,6 @@ export class ReplaceInput extends Widget {
256341
dom.addClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
257342
}
258343

259-
private buildDomNode(history: string[], flexibleHeight: boolean, flexibleWidth: boolean, flexibleMaxHeight: number | undefined): void {
260-
this.domNode = document.createElement('div');
261-
dom.addClass(this.domNode, 'monaco-findInput');
262-
263-
this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
264-
ariaLabel: this.label || '',
265-
placeholder: this.placeholder || '',
266-
validationOptions: {
267-
validation: this.validation
268-
},
269-
inputBackground: this.inputBackground,
270-
inputForeground: this.inputForeground,
271-
inputBorder: this.inputBorder,
272-
inputValidationInfoBackground: this.inputValidationInfoBackground,
273-
inputValidationInfoForeground: this.inputValidationInfoForeground,
274-
inputValidationInfoBorder: this.inputValidationInfoBorder,
275-
inputValidationWarningBackground: this.inputValidationWarningBackground,
276-
inputValidationWarningForeground: this.inputValidationWarningForeground,
277-
inputValidationWarningBorder: this.inputValidationWarningBorder,
278-
inputValidationErrorBackground: this.inputValidationErrorBackground,
279-
inputValidationErrorForeground: this.inputValidationErrorForeground,
280-
inputValidationErrorBorder: this.inputValidationErrorBorder,
281-
history,
282-
flexibleHeight,
283-
flexibleWidth,
284-
flexibleMaxHeight
285-
}));
286-
287-
this.preserveCase = this._register(new PreserveCaseCheckbox({
288-
appendTitle: '',
289-
isChecked: false,
290-
inputActiveOptionBorder: this.inputActiveOptionBorder,
291-
inputActiveOptionBackground: this.inputActiveOptionBackground,
292-
}));
293-
this._register(this.preserveCase.onChange(viaKeyboard => {
294-
this._onDidOptionChange.fire(viaKeyboard);
295-
if (!viaKeyboard && this.fixFocusOnOptionClickEnabled) {
296-
this.inputBox.focus();
297-
}
298-
this.validate();
299-
}));
300-
this._register(this.preserveCase.onKeyDown(e => {
301-
this._onPreserveCaseKeyDown.fire(e);
302-
}));
303-
304-
if (this._showOptionButtons) {
305-
this.cachedOptionsWidth = this.preserveCase.width();
306-
} else {
307-
this.cachedOptionsWidth = 0;
308-
}
309-
310-
// Arrow-Key support to navigate between options
311-
let indexes = [this.preserveCase.domNode];
312-
this.onkeydown(this.domNode, (event: IKeyboardEvent) => {
313-
if (event.equals(KeyCode.LeftArrow) || event.equals(KeyCode.RightArrow) || event.equals(KeyCode.Escape)) {
314-
let index = indexes.indexOf(<HTMLElement>document.activeElement);
315-
if (index >= 0) {
316-
let newIndex: number = -1;
317-
if (event.equals(KeyCode.RightArrow)) {
318-
newIndex = (index + 1) % indexes.length;
319-
} else if (event.equals(KeyCode.LeftArrow)) {
320-
if (index === 0) {
321-
newIndex = indexes.length - 1;
322-
} else {
323-
newIndex = index - 1;
324-
}
325-
}
326-
327-
if (event.equals(KeyCode.Escape)) {
328-
indexes[index].blur();
329-
} else if (newIndex >= 0) {
330-
indexes[newIndex].focus();
331-
}
332-
333-
dom.EventHelper.stop(event, true);
334-
}
335-
}
336-
});
337-
338-
339-
let controls = document.createElement('div');
340-
controls.className = 'controls';
341-
controls.style.display = this._showOptionButtons ? 'block' : 'none';
342-
controls.appendChild(this.preserveCase.domNode);
343-
344-
this.domNode.appendChild(controls);
345-
}
346-
347344
public validate(): void {
348345
if (this.inputBox) {
349346
this.inputBox.validate();

src/vs/base/node/processes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export abstract class AbstractProcess<TProgressData> {
122122
}
123123

124124
this.childProcess = null;
125+
this.childProcessPromise = null;
125126
this.terminateRequested = false;
126127

127128
if (this.options.env) {

src/vs/editor/common/config/editorOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,6 +1954,7 @@ class EditorQuickSuggestions extends BaseEditorOption<EditorOption.quickSuggesti
19541954
description: nls.localize('quickSuggestions', "Controls whether suggestions should automatically show up while typing.")
19551955
}
19561956
);
1957+
this.defaultValue = defaults;
19571958
}
19581959

19591960
public validate(_input: any): ValidQuickSuggestionsOptions {

src/vs/editor/standalone/browser/quickOpen/quickOpenEditorWidget.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ export class QuickOpenEditorWidget implements IOverlayWidget {
3131
constructor(codeEditor: ICodeEditor, onOk: () => void, onCancel: () => void, onType: (value: string) => void, configuration: IQuickOpenEditorWidgetOptions, themeService: IThemeService) {
3232
this.codeEditor = codeEditor;
3333
this.themeService = themeService;
34+
this.visible = false;
3435

35-
this.create(onOk, onCancel, onType, configuration);
36-
}
37-
38-
private create(onOk: () => void, onCancel: () => void, onType: (value: string) => void, configuration: IQuickOpenEditorWidgetOptions): void {
3936
this.domNode = document.createElement('div');
4037

4138
this.quickOpenWidget = new QuickOpenWidget(
@@ -107,4 +104,4 @@ export class QuickOpenEditorWidget implements IOverlayWidget {
107104

108105
return null;
109106
}
110-
}
107+
}

src/vs/workbench/browser/contextkeys.ts

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -88,41 +88,6 @@ export class WorkbenchContextKeysHandler extends Disposable {
8888
) {
8989
super();
9090

91-
this.initContextKeys();
92-
this.registerListeners();
93-
}
94-
95-
private registerListeners(): void {
96-
this.editorGroupService.whenRestored.then(() => this.updateEditorContextKeys());
97-
98-
this._register(this.editorService.onDidActiveEditorChange(() => this.updateEditorContextKeys()));
99-
this._register(this.editorService.onDidVisibleEditorsChange(() => this.updateEditorContextKeys()));
100-
101-
this._register(this.editorGroupService.onDidAddGroup(() => this.updateEditorContextKeys()));
102-
this._register(this.editorGroupService.onDidRemoveGroup(() => this.updateEditorContextKeys()));
103-
this._register(this.editorGroupService.onDidGroupIndexChange(() => this.updateEditorContextKeys()));
104-
105-
this._register(addDisposableListener(window, EventType.FOCUS_IN, () => this.updateInputContextKeys(), true));
106-
107-
this._register(this.contextService.onDidChangeWorkbenchState(() => this.updateWorkbenchStateContextKey()));
108-
this._register(this.contextService.onDidChangeWorkspaceFolders(() => this.updateWorkspaceFolderCountContextKey()));
109-
110-
this._register(this.configurationService.onDidChangeConfiguration(e => {
111-
if (e.affectsConfiguration('workbench.editor.openSideBySideDirection')) {
112-
this.updateSplitEditorsVerticallyContext();
113-
}
114-
}));
115-
116-
this._register(this.layoutService.onZenModeChange(enabled => this.inZenModeContext.set(enabled)));
117-
this._register(this.layoutService.onFullscreenChange(fullscreen => this.isFullscreenContext.set(fullscreen)));
118-
this._register(this.layoutService.onCenteredLayoutChange(centered => this.isCenteredLayoutContext.set(centered)));
119-
this._register(this.layoutService.onPanelPositionChange(position => this.panelPositionContext.set(position)));
120-
121-
this._register(this.viewletService.onDidViewletClose(() => this.updateSideBarContextKeys()));
122-
this._register(this.viewletService.onDidViewletOpen(() => this.updateSideBarContextKeys()));
123-
}
124-
125-
private initContextKeys(): void {
12691

12792
// Platform
12893
IsMacContext.bindTo(this.contextKeyService);
@@ -187,6 +152,38 @@ export class WorkbenchContextKeysHandler extends Disposable {
187152
// Panel Position
188153
this.panelPositionContext = PanelPositionContext.bindTo(this.contextKeyService);
189154
this.panelPositionContext.set(this.layoutService.getPanelPosition() === Position.RIGHT ? 'right' : 'bottom');
155+
156+
this.registerListeners();
157+
}
158+
159+
private registerListeners(): void {
160+
this.editorGroupService.whenRestored.then(() => this.updateEditorContextKeys());
161+
162+
this._register(this.editorService.onDidActiveEditorChange(() => this.updateEditorContextKeys()));
163+
this._register(this.editorService.onDidVisibleEditorsChange(() => this.updateEditorContextKeys()));
164+
165+
this._register(this.editorGroupService.onDidAddGroup(() => this.updateEditorContextKeys()));
166+
this._register(this.editorGroupService.onDidRemoveGroup(() => this.updateEditorContextKeys()));
167+
this._register(this.editorGroupService.onDidGroupIndexChange(() => this.updateEditorContextKeys()));
168+
169+
this._register(addDisposableListener(window, EventType.FOCUS_IN, () => this.updateInputContextKeys(), true));
170+
171+
this._register(this.contextService.onDidChangeWorkbenchState(() => this.updateWorkbenchStateContextKey()));
172+
this._register(this.contextService.onDidChangeWorkspaceFolders(() => this.updateWorkspaceFolderCountContextKey()));
173+
174+
this._register(this.configurationService.onDidChangeConfiguration(e => {
175+
if (e.affectsConfiguration('workbench.editor.openSideBySideDirection')) {
176+
this.updateSplitEditorsVerticallyContext();
177+
}
178+
}));
179+
180+
this._register(this.layoutService.onZenModeChange(enabled => this.inZenModeContext.set(enabled)));
181+
this._register(this.layoutService.onFullscreenChange(fullscreen => this.isFullscreenContext.set(fullscreen)));
182+
this._register(this.layoutService.onCenteredLayoutChange(centered => this.isCenteredLayoutContext.set(centered)));
183+
this._register(this.layoutService.onPanelPositionChange(position => this.panelPositionContext.set(position)));
184+
185+
this._register(this.viewletService.onDidViewletClose(() => this.updateSideBarContextKeys()));
186+
this._register(this.viewletService.onDidViewletOpen(() => this.updateSideBarContextKeys()));
190187
}
191188

192189
private updateEditorContextKeys(): void {

0 commit comments

Comments
 (0)