Skip to content

Commit 3e5a1a2

Browse files
committed
Fix multiple reflections mapping to the same file name
I don't like this fix, but `getAlias` isn't something that should exist to begin with, so... Resolves #2012
1 parent 55b72aa commit 3e5a1a2

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Unreleased
22

3+
### Bug Fixes
4+
5+
- Fixed multiple reflections mapping to the same file name on case insensitive file systems, #2012.
6+
37
## v0.23.8 (2022-07-17)
48

59
### Features

src/lib/models/reflections/abstract.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ export abstract class Reflection {
413413
if (alias === "") {
414414
alias = "reflection-" + this.id;
415415
}
416+
// NTFS/ExFAT use uppercase, so we will too. It probably won't matter
417+
// in this case since names will generally be valid identifiers, but to be safe...
418+
const upperAlias = alias.toUpperCase();
416419

417420
let target = this as Reflection;
418421
while (target.parent && !target.hasOwnDocument) {
@@ -422,12 +425,12 @@ export abstract class Reflection {
422425
target._aliases ||= new Map();
423426

424427
let suffix = "";
425-
if (!target._aliases.has(alias)) {
426-
target._aliases.set(alias, 1);
428+
if (!target._aliases.has(upperAlias)) {
429+
target._aliases.set(upperAlias, 1);
427430
} else {
428-
const count = target._aliases.get(alias)!;
431+
const count = target._aliases.get(upperAlias)!;
429432
suffix = "-" + count.toString();
430-
target._aliases.set(alias, count + 1);
433+
target._aliases.set(upperAlias, count + 1);
431434
}
432435

433436
alias += suffix;

src/test/converter2/issues/gh2012.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export function model(): number {
2+
return 1;
3+
}
4+
export function Model(): string {
5+
return "";
6+
}

src/test/issueTests.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,12 @@ export const issueTests: {
665665
equal(b.signatures![0].sources?.[0].line, 3);
666666
equal(b.signatures![0].sources?.[0].character, 0);
667667
},
668+
669+
gh2012(project) {
670+
project.hasOwnDocument = true;
671+
const model = query(project, "model");
672+
const Model = query(project, "Model");
673+
equal(model.getAlias(), "model");
674+
equal(Model.getAlias(), "Model-1");
675+
},
668676
};

0 commit comments

Comments
 (0)