Skip to content

Commit

Permalink
Self-conflict generated same names (incase mod collides with itself)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcssov committed Jun 9, 2024
1 parent 01342db commit 3f9ae0a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/IronyModManager.Services/ExternalEditorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
// Created : 12-07-2020
//
// Last Modified By : Mario
// Last Modified On : 07-10-2022
// Last Modified On : 06-09-2024
// ***********************************************************************
// <copyright file="ExternalEditorService.cs" company="Mario">
// Mario
// </copyright>
// <summary></summary>
// ***********************************************************************

using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -54,7 +55,7 @@ public ExternalEditorService(IPreferencesService preferenceService, IStorageProv
/// Gets the preferences service.
/// </summary>
/// <value>The preferences service.</value>
protected IPreferencesService PreferencesService { get; private set; }
protected IPreferencesService PreferencesService { get; }

#endregion Properties

Expand Down Expand Up @@ -84,10 +85,17 @@ static string getFilename(IDefinition definition)
}

var model = GetModelInstance<IExternalEditorFiles>();
var leftName = getFilename(left);
model.LeftDiff = DIResolver.Get<ITempFile>();
model.LeftDiff.Create(model.LeftDiff.GetTempFileName(getFilename(left)));
model.LeftDiff.Create(model.LeftDiff.GetTempFileName(leftName));
model.RightDiff = DIResolver.Get<ITempFile>();
model.RightDiff.Create(model.RightDiff.GetTempFileName(getFilename(right)));
var rightName = getFilename(right);
if (leftName.Equals(rightName, StringComparison.OrdinalIgnoreCase))
{
rightName = $"{rightName}_2";
}

model.RightDiff.Create(model.RightDiff.GetTempFileName(rightName));
return model;
}

Expand All @@ -105,6 +113,7 @@ public virtual string GetLaunchArguments(string leftLocation, string rightLocati
var launchArgs = IronyFormatter.Format($"{opts.ExternalEditorParameters}", new { Left = $"\"{leftLocation}\"", Right = $"\"{rightLocation}\"" });
return launchArgs;
}

return string.Empty;
}

Expand Down

0 comments on commit 3f9ae0a

Please sign in to comment.