Update close file logic to select prior if exists; bug fix in LSP regarding editor and assignment
This commit is contained in:
parent
ae60905eb4
commit
d6f766753c
@ -39,7 +39,23 @@ export class FilesService {
|
|||||||
return [...this.files.values()];
|
return [...this.files.values()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public delete(file: NewtonFile) {
|
public getPreviousFile(path: string): NewtonFile {
|
||||||
|
let paths = this.getAllPaths();
|
||||||
|
let i = paths.indexOf(path);
|
||||||
|
|
||||||
|
(i == 0) ? i += 1 : i -= 1;
|
||||||
|
return this.files.get( paths[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
public getNextFile(path: string): NewtonFile {
|
||||||
|
let paths = this.getAllPaths();
|
||||||
|
let i = paths.indexOf(path);
|
||||||
|
|
||||||
|
(i > paths.length) ? i -= 1 : i += 1;
|
||||||
|
return this.files.get( paths[i] );
|
||||||
|
}
|
||||||
|
|
||||||
|
public unset(file: NewtonFile) {
|
||||||
file.session.destroy();
|
file.session.destroy();
|
||||||
window.fs.closeFile(file.path);
|
window.fs.closeFile(file.path);
|
||||||
this.files.delete(file.path);
|
this.files.delete(file.path);
|
||||||
|
@ -131,16 +131,26 @@ export class EditorsComponent {
|
|||||||
|
|
||||||
for (let i = 0; i < editors.length; i++) {
|
for (let i = 0; i < editors.length; i++) {
|
||||||
let editorComponent = editors[i];
|
let editorComponent = editors[i];
|
||||||
if (editorComponent.editor.session == file.session) {
|
|
||||||
|
if (editorComponent.editor.session !== file.session) continue;
|
||||||
|
|
||||||
|
let targetFile = this.filesService.getPreviousFile(file.path)
|
||||||
|
if (targetFile) {
|
||||||
|
editorComponent.assignSession(targetFile);
|
||||||
|
if (activeComponent == editorComponent) {
|
||||||
|
this.editorsService.miniMapView.cloneSession(targetFile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
editorComponent.newFile();
|
||||||
if (activeComponent == editorComponent) {
|
if (activeComponent == editorComponent) {
|
||||||
this.editorsService.miniMapView.newFile();
|
this.editorsService.miniMapView.newFile();
|
||||||
}
|
}
|
||||||
editorComponent.newFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activeComponent.lspManagerService.closeDocument(file.session);
|
activeComponent.lspManagerService.closeDocument(file.session);
|
||||||
this.filesService.delete(file);
|
this.filesService.unset(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
<div class="col">
|
<div class="col">
|
||||||
Target Editor: <label [innerText]="editor?.id || '...'"></label>
|
Target Editor: <label [innerText]="editor?.id || '...'"></label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm" [hidden]="!lspManagerService.workspaceFolder">
|
<div class="col-sm" [hidden]="!lspManagerService.workspaceFolder">
|
||||||
<button class="btn btn-sm btn-dark"
|
<button class="btn btn-sm btn-dark"
|
||||||
(click)="registerEditorToLanguageClient()">
|
(click)="registerEditorToLanguageClient()">
|
||||||
|
@ -37,8 +37,6 @@ export class LspManagerComponent {
|
|||||||
activeFile: any;
|
activeFile: any;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +137,7 @@ export class LspManagerComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private editorUpdate(message: ServiceMessage) {
|
private editorUpdate(message: ServiceMessage) {
|
||||||
|
if (!this.editor) return;
|
||||||
if (!message.rawData.activeFile) return;
|
if (!message.rawData.activeFile) return;
|
||||||
|
|
||||||
this.editor.setSession(message.rawData.editor.getSession())
|
this.editor.setSession(message.rawData.editor.getSession())
|
||||||
|
Loading…
Reference in New Issue
Block a user