fix #40 - allow detection of filename for errors messages when building dmd

This commit is contained in:
Basile Burg 2020-05-12 22:06:21 +02:00
parent d646b8c296
commit 9ee7f4daab
1 changed files with 14 additions and 1 deletions

View File

@ -1239,6 +1239,9 @@ var
i: integer = 0;
ident: string = '';
absName: string;
nsr: string;
const
nonStandardRoot: array [0..3] of string = ('src', 'source', 'sources', 'import');
begin
result := false;
while (true) do
@ -1265,15 +1268,25 @@ begin
getMultiDocHandler.openDocument(ident);
exit(true);
end;
// if fname relative to project path
if fProj <> nil then
begin
// if fname relative to project path
absName := expandFilenameEx(fProj.filename.extractFileDir + DirectorySeparator, ident);
if absName.fileExists then
begin
getMultiDocHandler.openDocument(absName);
exit(true);
end;
for nsr in nonStandardRoot do
begin
// if fname is relative to <project path>/<nsr>
absName := expandFilenameEx(fProj.filename.extractFileDir + DirectorySeparator + nsr + DirectorySeparator, ident);
if absName.fileExists then
begin
getMultiDocHandler.openDocument(absName);
exit(true);
end;
end;
end;
// finally try using pwd ...
absName := expandFilenameEx(GetCurrentDir, ident);