Skip to content

Commit

Permalink
bugfix: go-to definition tests jumping
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed May 20, 2020
1 parent 48a35db commit 8082482
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/builtin-addons/core/template-definition-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isLinkToTarget, isLinkComponentRouteTarget } from './../../utils/ast-he
import ASTPath from './../../glimmer-utils';
import { getGlobalRegistry } from './../../utils/registry-api';
import { normalizeToClassicComponent } from '../../utils/normalizers';
import { isTemplatePath, getComponentNameFromURI, isModuleUnificationApp, getPodModulePrefix } from './../../utils/layout-helpers';
import { isTemplatePath, isTestFile, getComponentNameFromURI, isModuleUnificationApp, getPodModulePrefix } from './../../utils/layout-helpers';

import {
getAbstractHelpersParts,
Expand All @@ -26,7 +26,7 @@ export function getPathsFromRegistry(type: 'helper' | 'modifier' | 'component',
const absRoot = path.normalize(root);
const registry = getGlobalRegistry();
const bucket: any = registry[type].get(name) || new Set();
return Array.from(bucket).filter((el: string) => path.normalize(el).includes(absRoot) && fs.existsSync(el)) as string[];
return Array.from(bucket).filter((el: string) => path.normalize(el).includes(absRoot) && !isTestFile(path.normalize(el)) && fs.existsSync(el)) as string[];
}

export function provideComponentTemplatePaths(root: string, rawComponentName: string) {
Expand Down
12 changes: 12 additions & 0 deletions src/utils/layout-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,18 @@ export function isTemplatePath(filePath: string) {
return filePath.endsWith('.hbs');
}

export function normalizedPath(filePath: string) {
if (filePath.includes('\\')) {
return filePath.split('\\').join('/');
} else {
return filePath;
}
}

export function isTestFile(filePath: string) {
return normalizedPath(filePath).includes('/tests/');
}

export function hasAddonFolderInPath(name: string) {
return name.includes(path.sep + 'addon' + path.sep);
}
Expand Down

0 comments on commit 8082482

Please # to comment.