From 9863dc2f909b15ed8048dd250e4c4295e4a62a68 Mon Sep 17 00:00:00 2001 From: Francesco Stasi Date: Tue, 23 Nov 2021 12:16:56 +0100 Subject: [PATCH] Fix editor tabs order (#612) --- .../src/browser/arduino-frontend-contribution.tsx | 1 - .../src/browser/theia/core/shell-layout-restorer.ts | 13 +++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx index 2054cdcdb..8352f6dc1 100644 --- a/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx +++ b/arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx @@ -508,7 +508,6 @@ export class ArduinoFrontendContribution for (const uri of [mainFileUri, ...rootFolderFileUris]) { await this.ensureOpened(uri); } - await this.ensureOpened(mainFileUri, true); if (mainFileUri.endsWith('.pde')) { const message = nls.localize( 'arduino/common/oldFormat', diff --git a/arduino-ide-extension/src/browser/theia/core/shell-layout-restorer.ts b/arduino-ide-extension/src/browser/theia/core/shell-layout-restorer.ts index 92ad44237..a72c89bf1 100644 --- a/arduino-ide-extension/src/browser/theia/core/shell-layout-restorer.ts +++ b/arduino-ide-extension/src/browser/theia/core/shell-layout-restorer.ts @@ -35,13 +35,18 @@ export class ShellLayoutRestorer extends TheiaShellLayoutRestorer { const layoutData = await this.inflate(serializedLayoutData); // workaround to remove duplicated tabs + const filesUri: string[] = []; if ((layoutData as any)?.mainPanel?.main?.widgets) { (layoutData as any).mainPanel.main.widgets = ( layoutData as any - ).mainPanel.main.widgets.filter( - (widget: any) => - widget.constructionOptions.factoryId !== 'code-editor-opener' - ); + ).mainPanel.main.widgets.filter((widget: any) => { + const uri = widget.getResourceUri().toString(); + if (filesUri.includes(uri)) { + return false; + } + filesUri.push(uri); + return true; + }); } await app.shell.setLayoutData(layoutData);