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

Commit 59ec828

Browse files
committed
Fix 1023494: Unsaved new documents have / added to begining of file name
Includes also test
1 parent 3c8a4d8 commit 59ec828

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
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: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
using IdeUnitTests;
3232
using MonoDevelop.Components;
3333
using MonoDevelop.Core;
34+
using MonoDevelop.Ide.Fonts;
3435
using MonoDevelop.Ide.Gui.Shell;
3536
using MonoDevelop.Ide.TypeSystem;
3637
using MonoDevelop.Projects;
@@ -39,7 +40,8 @@
3940

4041
namespace MonoDevelop.Ide.Gui.Documents
4142
{
42-
[RequireService(typeof(TypeSystemService))]
43+
[RequireService (typeof (TypeSystemService))]
44+
[RequireService (typeof (FontService))]
4345
public class DocumentManagerTests : TestBase
4446
{
4547
// BasicServiceProvider serviceProvider;
@@ -228,6 +230,15 @@ async Task DontClose (object s, DocumentCloseEventArgs e)
228230
e.Cancel = true;
229231
}
230232

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+
231242
[Test]
232243
public async Task GetDocument ()
233244
{

0 commit comments

Comments
 (0)