Skip to content

Commit

Permalink
Merge pull request #2474 from yoyo930021/fix-high-cpu-when-template-s…
Browse files Browse the repository at this point in the history
…elf-close

Fix high cpu when template self close
  • Loading branch information
yoyo930021 authored Nov 16, 2020
2 parents 03a4373 + d38849a commit 5ea6a5c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/src/embeddedSupport/vueDocumentRegionParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function scanTemplateRegion(scanner: Scanner, text: string): EmbeddedRegion | nu
while (unClosedTemplate !== 0) {
// skip parsing on non html syntax, just search terminator
if (token === TokenType.AttributeValue && languageId !== 'vue-html') {
while (token !== TokenType.StartTagClose) {
while (![TokenType.StartTagClose, TokenType.StartTagSelfClose].includes(token)) {
token = scanner.scan();
}
start = scanner.getTokenEnd();
Expand Down
11 changes: 11 additions & 0 deletions test/lsp/features/external/basic.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { testCompletion } from '../../../completionHelper';
import { position } from '../../../util';
import { getDocUri } from '../../path';

describe('Should use external file in Vue SFC', () => {
const docUri = getDocUri('external/Foo.vue');

it('Should work fine when template self close', async () => {
await testCompletion(docUri, position(2, 0), ['<style> css-scoped.vue ✌']);
});
});
1 change: 1 addition & 0 deletions test/lsp/fixture/external/Foo.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
div
5 changes: 5 additions & 0 deletions test/lsp/fixture/external/Foo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Vue from 'vue';

export default Vue.extend({
name: 'Foo'
});
3 changes: 3 additions & 0 deletions test/lsp/fixture/external/Foo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template lang="pug" src="./Foo.pug" />
<script lang="ts" src="./Foo.ts" />

0 comments on commit 5ea6a5c

Please sign in to comment.