Skip to content

Commit

Permalink
Fix vuejs#1386 again
Browse files Browse the repository at this point in the history
  • Loading branch information
octref authored and yoyo930021 committed Oct 28, 2019
1 parent f13544b commit 02bd149
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/src/modes/vue/snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ function loadAllSnippets(rootDir: string, source: SnippetSource): Snippet[] {

try {
fs.readdirSync(rootDir).forEach(p => {
if (p === 'template' || p === 'style' || p === 'script') {
return;
}
const absPath = path.resolve(rootDir, p);
if (!absPath.endsWith('.vue') && fs.existsSync(absPath) && fs.lstatSync(absPath).isDirectory()) {
const customDirSnippets = loadSnippetsFromDir(absPath, source, 'custom').map(s => {
Expand Down
45 changes: 45 additions & 0 deletions test/lsp/completion/scaffold.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { activateLS, showFile, sleep, FILE_LOAD_SLEEP_TIME } from '../helper';
import { position, getDocUri } from '../util';
import { testCompletion } from './helper';

describe('Should autocomplete scaffold snippets', () => {
const scriptDocUri = getDocUri('client/completion/script/Scaffold.vue');

before('activate', async () => {
await activateLS();
await showFile(scriptDocUri);
await sleep(FILE_LOAD_SLEEP_TIME);
// TS LS completion starts slow.
await sleep(2000);
});

it('completes all scaffold snippets', async () => {
await testCompletion(scriptDocUri, position(0, 1), [
'<vue> with default.vue ✌',
'<template> html.vue ✌',
'<template> pug.vue ✌',
'<style> css-scoped.vue ✌',
'<style> css.vue ✌',
'<style> less-scoped.vue ✌',
'<style> less.vue ✌',
'<style> postcss-scoped.vue ✌',
'<style> postcss.vue ✌',
'<style> sass-scoped.vue ✌',
'<style> sass.vue ✌',
'<style> scss-scoped.vue ✌',
'<style> scss.vue ✌',
'<style> stylus-scoped.vue ✌',
'<style> stylus.vue ✌',
'<script> javascript.vue ✌',
'<script> typescript.vue ✌'
]);
});

it('completes project wide scaffold snippets', async () => {
await testCompletion(scriptDocUri, position(0, 1), [
{
label: '<vue> with foo.vue 💼'
}
]);
});
});
3 changes: 3 additions & 0 deletions test/lsp/fixture/.vscode/vetur/snippets/foo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div>foo</div>
</template>
1 change: 1 addition & 0 deletions test/lsp/fixture/client/completion/script/Scaffold.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<

0 comments on commit 02bd149

Please sign in to comment.