Skip to content

Commit

Permalink
fix: source.organizeImports not working in editor.codeActionsOnSave
Browse files Browse the repository at this point in the history
close #906
  • Loading branch information
johnsoncodehk committed Mar 1, 2022
1 parent 766d4c4 commit 0abd930
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/vue-code-gen/src/generators/script.ts
Expand Up @@ -193,6 +193,8 @@ export function generate(
if (!scriptSetupRanges)
return;

const fullStart = codeGen.getText().length;

codeGen.addCode(
scriptSetup.content.substring(0, scriptSetupRanges.importSectionEndOffset),
{
Expand Down Expand Up @@ -369,6 +371,23 @@ export function generate(

codeGen.addText(`});\n`);
codeGen.addText(`})();\n`);

// for fix https://github.com/johnsoncodehk/volar/issues/906
codeGen.addMapping2({
mappedRange: {
start: fullStart,
end: codeGen.getText().length,
},
sourceRange: {
start: 0,
end: scriptSetup.content.length,
},
mode: SourceMaps.Mode.Totally,
data: {
vueTag: 'scriptSetup',
capabilities: {},
},
});
}
function writeExportOptions() {
codeGen.addText(`\n`);
Expand Down

0 comments on commit 0abd930

Please sign in to comment.