mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 23:06:49 +01:00
Add firstOrDefault helper
Array accesses are not strict null checked. Added a type checked helper for when you just want to get the first element of an array of fallback to a default if the array is empty
This commit is contained in:
@@ -1665,11 +1665,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
|
||||
|
||||
getWindowById(windowId: number): ICodeWindow | undefined {
|
||||
const res = WindowsManager.WINDOWS.filter(window => window.id === windowId);
|
||||
if (res && res.length === 1) {
|
||||
return res[0];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return arrays.firstOrDefault(res);
|
||||
}
|
||||
|
||||
getWindows(): ICodeWindow[] {
|
||||
|
||||
Reference in New Issue
Block a user