Skip to content

Commit a934c2b

Browse files
committed
Use normalized relative paths during conflict checking
This is to prevent false negatives from mismatched path formats.
1 parent e1435bc commit a934c2b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

sources/SilkTouch/SilkTouch/Mods/PrettifyNames.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ await proj.GetCompilationAsync(ct)
200200
var typeNamesLongestFirst = typeNames.OrderByDescending(x => x.Key.Length).ToArray();
201201

202202
var documentPaths = proj
203-
.Documents.Select(d => d.FilePath)
203+
.Documents.Select(d => d.RelativePath())
204204
.Where(d => d != null)
205205
.ToHashSet();
206206

@@ -223,12 +223,13 @@ await proj.GetCompilationAsync(ct)
223223

224224
// Rename doc and update path
225225
var originalName = doc.Name;
226-
var originalPath = doc.FilePath;
226+
var originalPath = doc.RelativePath();
227227
doc = doc.ReplaceNameAndPath(oldName, newName);
228+
var newPath = doc.RelativePath();
228229

229230
// Check for path conflict
230231
documentPaths.Remove(originalPath);
231-
if (!documentPaths.Add(doc.FilePath!))
232+
if (!documentPaths.Add(newPath))
232233
{
233234
logger.LogError(
234235
$"{originalName} -> {doc.Name} failed to rename file as a file already exists at {doc.FilePath}"

0 commit comments

Comments
 (0)