| 936 | // them (`mormot.core.os.pas` for `mormot.core.os.posix.inc`): how many |
| 937 | // characters of its path a file shares, the directory counting first. |
| 938 | const shared = (f: string): number => { |
| 939 | let n = 0; |
| 940 | while (n < f.length && n < incFile.length && f.charCodeAt(n) === incFile.charCodeAt(n)) n++; |
| 941 | return f.lastIndexOf('/', n - 1) * 1000 + n; |
| 942 | }; |
| 943 | const candidates = projectFiles(context).pascal.filter((f) => f !== incFile) |
| 944 | .map((f) => ({ f, n: shared(f) })).sort((a, b) => b.n - a.n).slice(0, 40); |
| 945 | const includer = candidates.find(({ f }) => includesOf(f, context).includes(incFile))?.f ?? null; |