Skip to content

Commit 4ce070f

Browse files
committed
feat: fix comments not disabling filepath validation
1 parent 183974d commit 4ce070f

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

packages/server/src/validations/validateFilePath.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
1515
const pattern =
1616
/(?:\/\*.*?(?=\*\/))|(\t*(?:ScriptPath|IncludeFile|LogoFile|FilePath|SkinFile)\s*=\s*)(.*?)(?=(?:$|\/\/|\/\*|(?:\s+(?:\/\/.*|\/\*.*))))/dgms;
1717

18-
const commentPattern = /(\/\/[^\n]*\n)|(\/\*.*?\*\/)/dgms;
18+
const commentPattern = /(\/\/[^\n]*[\r\n])|(\/\*.*(\*\/))/dgms;
1919
const commentRanges = text.matchAll(commentPattern);
2020

2121
let m: RegExpExecArray | null;
@@ -27,21 +27,29 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
2727
(m = pattern.exec(text)) &&
2828
problems < configService.globalSettings.maxNumberOfProblems
2929
) {
30+
console.log(m);
3031
let skip = false;
31-
for (const comment of commentRanges) {
32-
if (!(comment.index && comment.length)) {
32+
for (const comment of text.matchAll(commentPattern)) {
33+
console.log('Comment:', comment);
34+
if (!comment.index) {
35+
console.log('no index');
36+
3337
continue;
3438
}
39+
3540
skip =
36-
(comment.index < m.index && comment.index + comment.length > m.index) ||
37-
(comment.index > m.index && comment.index < m.index + m.length);
38-
}
41+
(comment.index <= m.index &&
42+
comment.index + comment[0].length >= m.index) ||
43+
(comment.index >= m.index && comment.index <= m.index + m[0].length);
3944

40-
if (skip) {
41-
continue;
45+
console.log('Skip: ', skip);
46+
if (skip) {
47+
break;
48+
}
4249
}
50+
4351
const normalizedPath = m[2] ? normalize(m[2].trim()) : null;
44-
if (normalizedPath && !checkIfPathExists(normalizedPath)) {
52+
if (!skip && normalizedPath && !checkIfPathExists(normalizedPath)) {
4553
problems++;
4654
const diagnostic: Diagnostic = {
4755
severity: DiagnosticSeverity.Error,

0 commit comments

Comments
 (0)