Skip to content

Commit a4b3656

Browse files
amiraliescristianoc
authored andcommitted
Use current file length as max range
1 parent 65f1474 commit a4b3656

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

server/src/server.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,13 @@ function format(msg: p.RequestMessage): Array<m.Message> {
398398
extension === c.resiExt
399399
);
400400
if (formattedResult.kind === "success") {
401+
let max = code.length;
401402
let result: p.TextEdit[] = [
402403
{
403-
range: utils.getSourceRange(code),
404+
range: {
405+
start: { line: 0, character: 0 },
406+
end: { line: max, character: max },
407+
},
404408
newText: formattedResult.result,
405409
},
406410
];

server/src/utils.ts

-20
Original file line numberDiff line numberDiff line change
@@ -476,23 +476,3 @@ export let parseCompilerLogOutput = (
476476

477477
return { done, result };
478478
};
479-
480-
export let getSourceRange = (source: string): p.Range => {
481-
let start = { line: 0, character: 0 };
482-
483-
// Calculate end position
484-
let len = source.length;
485-
let line = 1;
486-
let colStartIndex = 0;
487-
488-
for (let i = 0; i < len; i++) {
489-
if (source[i] === "\n") {
490-
line++;
491-
colStartIndex = i + 1;
492-
}
493-
}
494-
495-
let end = { line: line, character: len - colStartIndex };
496-
497-
return { start, end };
498-
};

0 commit comments

Comments
 (0)