Skip to content
This repository was archived by the owner on Oct 4, 2021. It is now read-only.

Commit 3d8291d

Browse files
authored
Merge pull request #9347 from mono/dev/davkar/fix1023494
Fix 1023494: Unsaved new documents have `/` added to begining of file name
2 parents 8af80e7 + 59ec828 commit 3d8291d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Documents/FileDocumentController.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// THE SOFTWARE.
2626

2727
using System;
28+
using System.IO;
2829
using System.Threading.Tasks;
2930
using MonoDevelop.Core;
3031
using System.Text;
@@ -57,7 +58,11 @@ public FilePath FilePath {
5758
}
5859
set {
5960
if (value != filePath) {
60-
filePath = value.CanonicalPath;
61+
if (Path.IsPathRooted(value)) {
62+
filePath = value.CanonicalPath;
63+
} else {
64+
filePath = value;
65+
}
6166
defaultMimeType = null;
6267
OnFileNameChanged ();
6368

main/tests/Ide.Tests/MonoDevelop.Ide.Gui.Documents/DocumentManagerTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,15 @@ async Task DontClose (object s, DocumentCloseEventArgs e)
230230
e.Cancel = true;
231231
}
232232

233+
[Test]
234+
public async Task NewDocumentFileNameMayNotChange ()
235+
{
236+
const string newName = "SomeFileName.txt";
237+
var doc = await documentManager.NewDocument (newName, "text/plain", "");
238+
//Since this is just "unsaved/new" file, its expected that Name and FileName are matching
239+
Assert.AreEqual (doc.Name, doc.FileName.ToString ());
240+
}
241+
233242
[Test]
234243
public async Task GetDocument ()
235244
{

0 commit comments

Comments
 (0)