Skip to content

Commit bed1137

Browse files
authored
Merge pull request #180 from mkslanc/fix-rename-doc
Fix: document renaming logic
2 parents c286d85 + 2f21aa4 commit bed1137

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

packages/ace-linters/src/language-provider.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,15 @@ export class LanguageProvider {
5454
private $hoverTooltip: HoverTooltip;
5555
$urisToSessionsIds: { [uri: string]: string } = {};
5656
workspaceUri: string;
57-
requireFilePath: boolean = false;
5857
private $lightBulbWidgets: { [editorId: string]: LightbulbWidget } = {};
5958
private stylesEmbedded: boolean;
6059
private inlineCompleter?: any;
6160
private doLiveAutocomplete: (e) => void;
62-
private completerAdapter?: { InlineCompleter: any; doLiveAutocomplete: (e) => void; validateAceInlineCompleterWithEditor: (editor: Ace.Editor) => void; };
61+
private completerAdapter?: {
62+
InlineCompleter: any;
63+
doLiveAutocomplete: (e) => void;
64+
validateAceInlineCompleterWithEditor: (editor: Ace.Editor) => void;
65+
};
6366

6467
private constructor(worker: Worker, options?: ProviderOptions) {
6568
this.$messageController = new MessageController(worker, this);
@@ -141,7 +144,6 @@ export class LanguageProvider {
141144
});
142145

143146
this.options.markdownConverter ||= new showdown.Converter();
144-
this.requireFilePath = this.options.requireFilePath ?? false;
145147
if (options?.workspacePath) {
146148
this.workspaceUri = convertToUri(options.workspacePath);
147149
}
@@ -621,7 +623,6 @@ class SessionLanguageProvider {
621623
private $isConnected = false;
622624
private $options?: ServiceOptions;
623625
private $filePath: string;
624-
private $isFilePathRequired = false;
625626
private $servicesCapabilities?: { [serviceName: string]: lsp.ServerCapabilities };
626627
private $requestsQueue: Function[] = [];
627628

@@ -655,7 +656,6 @@ class SessionLanguageProvider {
655656
this.$messageController = messageController;
656657
this.session = session;
657658
this.editor = editor;
658-
this.$isFilePathRequired = provider.requireFilePath;
659659

660660
session.doc.version = 1;
661661
session.doc.on("change", this.$changeListener, true);
@@ -689,8 +689,6 @@ class SessionLanguageProvider {
689689
setFilePath(filePath: string) {
690690
this.enqueueIfNotConnected(() => {
691691
this.session.doc.version++;
692-
if (this.$filePath !== undefined)//TODO change file path
693-
return;
694692
this.$filePath = filePath;
695693
const previousComboId = this.comboDocumentIdentifier;
696694
this.initDocumentUri(true);
@@ -699,8 +697,6 @@ class SessionLanguageProvider {
699697
};
700698

701699
private $init() {
702-
if (this.$isFilePathRequired && this.$filePath === undefined)
703-
return;
704700
this.initDocumentUri();
705701
this.$messageController.init(this.comboDocumentIdentifier, this.session.doc, this.$mode, this.$options, this.$connected);
706702
}

packages/ace-linters/src/services/base-service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ export abstract class BaseService<OptionsType extends ServiceOptions = ServiceOp
131131
}
132132

133133
renameDocument(document: lsp.TextDocumentIdentifier, newDocumentUri: string) {
134-
this.documents[newDocumentUri] = this.documents[document.uri];
134+
const previousDocument = this.getDocument(document.uri);
135+
this.addDocument({
136+
uri: newDocumentUri,
137+
version: previousDocument.version,
138+
languageId: previousDocument.languageId,
139+
text: previousDocument.getText()
140+
})
135141
this.options[newDocumentUri] = this.options[document.uri];
136142
this.removeDocument(document);
137143
}

packages/ace-linters/src/types/language-service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ export interface ProviderOptions {
255255
codeActions?: boolean
256256
},
257257
markdownConverter?: MarkDownConverter,
258-
requireFilePath?: boolean,
259258
workspacePath?: string, // this would be transformed to workspaceUri
260259
aceComponents?: {
261260
"InlineAutocomplete"?: typeof InlineAutocomplete,

packages/demo/file-api-websockets/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ new AceLayout(base);
3030
window["fileTreeWrapper"] = fileTree;
3131
let fileSystem = new FileSystemWeb();
3232
let aceTree = new AceTreeWrapper();
33+
aceTree.render();
3334

3435
function renderFileTree() {
3536
let button = new Button({value: "Open Folder"});

packages/demo/file-api-websockets/webworker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ manager.registerServer("astro", {
106106

107107
manager.registerServer("go", {
108108
module: () => import("ace-linters/build/language-client"),
109-
modes: "golang",
109+
modes: "golang|go",
110110
type: "socket",
111111
socket: new WebSocket("ws://127.0.0.1:3030/go")
112112
});

0 commit comments

Comments
 (0)