(tab: IEditorTab, groupId?: UniqueId)
| 319 | } |
| 320 | |
| 321 | public updateTab(tab: IEditorTab, groupId?: UniqueId): IEditorTab { |
| 322 | let updatedTab; |
| 323 | const editorValue = tab?.data?.value; |
| 324 | if (groupId) { |
| 325 | const group = this.getGroupById(groupId); |
| 326 | |
| 327 | if (group?.data?.length) { |
| 328 | const tabData = group.data.find(searchById(tab.id)); |
| 329 | |
| 330 | if (tabData) { |
| 331 | updatedTab = Object.assign(tabData, tab); |
| 332 | } |
| 333 | if (group.activeTab === tab.id) { |
| 334 | updatedTab = Object.assign(group.tab, tab); |
| 335 | } |
| 336 | // Update model's value |
| 337 | const model = MonacoEditor.getModel( |
| 338 | Uri.parse(tab.id.toString()) |
| 339 | ); |
| 340 | const currentValue = model?.getValue(); |
| 341 | if ( |
| 342 | model && |
| 343 | isString(editorValue) && |
| 344 | currentValue !== editorValue |
| 345 | ) { |
| 346 | model.setValue(editorValue); |
| 347 | } |
| 348 | this.updateGroup(groupId, group); |
| 349 | |
| 350 | if (groupId === this.state.current?.id) { |
| 351 | this.updateCurrentGroup(group); |
| 352 | } |
| 353 | } |
| 354 | } else { |
| 355 | const { groups = [], current } = this.state; |
| 356 | groups.forEach((group) => { |
| 357 | const tabData = this.getTabById(tab.id!, group.id!); |
| 358 | if (tabData) { |
| 359 | updatedTab = Object.assign(tabData, tab); |
| 360 | } |
| 361 | |
| 362 | if (group.activeTab === tab.id) { |
| 363 | updatedTab = Object.assign(group.tab, tab); |
| 364 | } |
| 365 | |
| 366 | // Update model's value |
| 367 | const model = MonacoEditor.getModel( |
| 368 | Uri.parse(tab.id.toString()) |
| 369 | ); |
| 370 | const currentValue = model?.getValue(); |
| 371 | if ( |
| 372 | model && |
| 373 | isString(editorValue) && |
| 374 | currentValue !== editorValue |
| 375 | ) { |
| 376 | model.setValue(editorValue); |
| 377 | } |
| 378 | }); |
nothing calls this directly
no test coverage detected