Skip to content

Fix issue with crash on rename. #394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,16 @@ function documentSymbol(msg: p.RequestMessage) {
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_documentSymbol
let params = msg.params as p.DocumentSymbolParams;
let filePath = fileURLToPath(params.textDocument.uri);
let code = getOpenedFileContent(params.textDocument.uri);
let extension = path.extname(params.textDocument.uri);
if (extension !== c.resExt && extension !== c.resiExt) {
// Can be called on renamed extension after rename
return {
jsonrpc: c.jsonrpcVersion,
id: msg.id,
result: null,
};
}
let code = getOpenedFileContent(params.textDocument.uri);
let tmpname = utils.createFileInTempDir(extension);
fs.writeFileSync(tmpname, code, { encoding: "utf-8" });
let response = utils.runAnalysisCommand(
Expand All @@ -397,8 +405,16 @@ function semanticTokens(msg: p.RequestMessage) {
// https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_semanticTokens
let params = msg.params as p.SemanticTokensParams;
let filePath = fileURLToPath(params.textDocument.uri);
let code = getOpenedFileContent(params.textDocument.uri);
let extension = path.extname(params.textDocument.uri);
if (extension !== c.resExt && extension !== c.resiExt) {
// Can be called on renamed extension after rename
return {
jsonrpc: c.jsonrpcVersion,
id: msg.id,
result: null,
};
}
let code = getOpenedFileContent(params.textDocument.uri);
let tmpname = utils.createFileInTempDir(extension);
fs.writeFileSync(tmpname, code, { encoding: "utf-8" });
let response = utils.runAnalysisCommand(
Expand Down