Skip to content

Commit

Permalink
Fix #3657
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyo930021 committed Feb 23, 2023
1 parent 5712e9e commit 0fa1879
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
16 changes: 13 additions & 3 deletions server/src/services/typescriptService/serviceHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { RuntimeLibrary } from '../dependencyService';
import { EnvironmentService } from '../EnvironmentService';
import { VueVersion } from '../../utils/vueVersion';
import { dirname } from 'path';
import { flatten } from 'lodash';

const NEWLINE = process.platform === 'win32' ? '\r\n' : '\n';

Expand Down Expand Up @@ -535,9 +536,18 @@ function defaultIgnorePatterns(tsModule: RuntimeLibrary['typescript'], projectPa
if (!gitignore) {
return nodeModules;
}
const parsed: string[] = parseGitIgnore(gitignore);
const filtered = parsed.filter(s => !s.startsWith('!'));
return nodeModules.concat(filtered);
try {
const parsedGlobs = parseGitIgnore.globs(gitignore);
const ignoreGlobs: string[] = flatten(
parsedGlobs
.filter((r: { type: 'ignore' | 'unignore' }) => r.type === 'ignore')
.map((r: { patterns: string[] }) => r.patterns)
);
const filtered = ignoreGlobs.filter(s => !s.startsWith('!'));
return nodeModules.concat(filtered);
} catch (_) {
return nodeModules;
}
}

function getScriptKind(tsModule: RuntimeLibrary['typescript'], langId: string): ts.ScriptKind {
Expand Down
25 changes: 25 additions & 0 deletions test/lsp/fixture/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.DS_Store
npm-debug.log

node_modules
.vscode-test

test/**/data-dir/**
!test/**/data-dir/User
test/**/data-dir/User/**
!test/**/data-dir/User/settings.json

dist
server/dist
server/typings
docs/.vuepress/dist
dist-test/
server/dist-test/

*.zip
*.vsix

.nyc_output
coverage.lcov

**/*.tsbuildinfo

0 comments on commit 0fa1879

Please sign in to comment.