|
1 | 1 | import { |
2 | 2 | CancellationTokenSource, |
| 3 | + Tab, |
3 | 4 | TabInputWebview, |
4 | 5 | Uri, |
5 | 6 | ViewColumn, |
@@ -156,30 +157,28 @@ export class ModelEditorView extends AbstractWebview< |
156 | 157 |
|
157 | 158 | private isAModelEditorOpen(): boolean { |
158 | 159 | return window.tabGroups.all.some((tabGroup) => |
159 | | - tabGroup.tabs.some((tab) => { |
160 | | - const viewType = |
161 | | - tab.input instanceof TabInputWebview ? tab.input.viewType : undefined; |
162 | | - |
163 | | - // The viewType has a prefix, such as "mainThreadWebview-", but if the |
164 | | - // suffix matches that should be enough to identify the view. |
165 | | - return viewType && viewType.endsWith("model-editor"); |
166 | | - }), |
| 160 | + tabGroup.tabs.some((tab) => this.isTabModelEditorView(tab)), |
167 | 161 | ); |
168 | 162 | } |
169 | 163 |
|
170 | 164 | private isAModelEditorActive(): boolean { |
171 | 165 | return window.tabGroups.all.some((tabGroup) => |
172 | | - tabGroup.tabs.some((tab) => { |
173 | | - const viewType = |
174 | | - tab.input instanceof TabInputWebview ? tab.input.viewType : undefined; |
175 | | - |
176 | | - // The viewType has a prefix, such as "mainThreadWebview-", but if the |
177 | | - // suffix matches that should be enough to identify the view. |
178 | | - return viewType && viewType.endsWith("model-editor") && tab.isActive; |
179 | | - }), |
| 166 | + tabGroup.tabs.some( |
| 167 | + (tab) => this.isTabModelEditorView(tab) && tab.isActive, |
| 168 | + ), |
180 | 169 | ); |
181 | 170 | } |
182 | 171 |
|
| 172 | + private isTabModelEditorView(tab: Tab): boolean { |
| 173 | + if (!(tab.input instanceof TabInputWebview)) { |
| 174 | + return false; |
| 175 | + } |
| 176 | + |
| 177 | + // The viewType has a prefix, such as "mainThreadWebview-", but if the |
| 178 | + // suffix matches that should be enough to identify the view. |
| 179 | + return tab.input.viewType.endsWith("model-editor"); |
| 180 | + } |
| 181 | + |
183 | 182 | protected async getPanelConfig(): Promise<WebviewPanelConfig> { |
184 | 183 | return { |
185 | 184 | viewId: "model-editor", |
|
0 commit comments