Skip to content

Commit

Permalink
fix: import module with line break
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-He95 committed Jul 23, 2024
1 parent 091f1ad commit 67a4642
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ export function activate(context: vscode.ExtensionContext) {
let pos: any = null
if (isVue) {
if (loc) {
if (getLineText(loc.start.line)?.trim()) {
str += '\n'
}
pos = createPosition(loc.start.line, 0)
}
else {
Expand All @@ -175,6 +178,7 @@ export function activate(context: vscode.ExtensionContext) {
pos = createPosition(0, 0)
}
}

updateText((edit) => {
edit.insert(pos, str)
})
Expand Down Expand Up @@ -257,9 +261,9 @@ export function activate(context: vscode.ExtensionContext) {
const result = parser(document.getText(), p)
if (!result)
return
if (position.active === ':' && result.type === 'text') {
if (position.active === ':' && result.type === 'text')
return
}

const lan = getActiveTextEditorLanguageId()
const isVue = lan === 'vue' && result.template
const code = getActiveText()
Expand Down

0 comments on commit 67a4642

Please sign in to comment.