Skip to content

Commit

Permalink
Fixes for pane-renaming in various scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
OfekShilon committed Aug 22, 2024
1 parent 09fc2c1 commit 047cd57
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
9 changes: 6 additions & 3 deletions static/multifile-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,13 @@ export class MultifileService {
if (!this.fileExists(value, file)) {
file.filename = value;

if (editor) {
editor.setFilename(file.filename);
// The rename click opened the editor if it was closed
if (file.isOpen && file.editorId > 0) {
editor = this.hub.getEditorById(file.editorId);
if (editor) {
editor.setFilename(file.filename);
}
}

resolve(true);
} else {
this.alertSystem.alert('Rename file', 'Filename already exists');
Expand Down
6 changes: 3 additions & 3 deletions static/panes/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1912,10 +1912,10 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
}

override getPaneName(): string {
if (this.filename) {
return this.filename;
} else if (this.paneName) {
if (this.paneName) {
return this.paneName;
} else if (this.filename) {
return this.filename;
} else {
return this.currentLanguage?.name + ' source #' + this.id;
}
Expand Down
9 changes: 6 additions & 3 deletions static/panes/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,12 @@ export class Tree {
}

private paneRenamedExternally() {
this.multifileService.forEachFile(
(file: MultifileFile) => (file.filename = this.hub.getEditorById(file.editorId)?.getPaneName() ?? ''),
);
this.multifileService.forEachFile((file: MultifileFile) => {
const editor = this.hub.getEditorById(file.editorId);
if (editor) {
file.filename = editor.getPaneName();
}
});
this.refresh();
}

Expand Down

0 comments on commit 047cd57

Please sign in to comment.