diff options
author | Matt Ward <matt.ward@microsoft.com> | 2018-04-11 20:36:54 +0300 |
---|---|---|
committer | Matt Ward <matt.ward@microsoft.com> | 2018-04-11 20:36:54 +0300 |
commit | b7ceabd5d60bba8fc6deab39557c2e982b0b8828 (patch) | |
tree | 8ff893a55d8ea1974c5213f1bc80249bc4957515 /main/src/core | |
parent | 02b84723596bfcad20a5e720c7f83facc6ac656e (diff) | |
parent | 6d9d8f23c4fe87c5a7d67fa08a4d5d642e8ae012 (diff) |
Merge branch 'master' into xamarin-forms-use-dotnet-templating-project-templates
Diffstat (limited to 'main/src/core')
10 files changed, 60 insertions, 19 deletions
diff --git a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/Document/DocumentUpdateRequest.cs b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/Document/DocumentUpdateRequest.cs index dded9bdb91..b9062ebf67 100644 --- a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/Document/DocumentUpdateRequest.cs +++ b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/Document/DocumentUpdateRequest.cs @@ -74,7 +74,9 @@ namespace Mono.TextEditor class MultipleLineUpdate : DocumentUpdateRequest { int start, end; - + + public bool RemoveLineCache { get; set; } + public MultipleLineUpdate (int start, int end) { this.start = start; @@ -84,8 +86,15 @@ namespace Mono.TextEditor public override void Update (MonoTextEditor editor) { if (start == end) { + if (RemoveLineCache) + editor.TextViewMargin.RemoveCachedLine (start); editor.RedrawLine (start); } else { + if (RemoveLineCache) { + for (int i = start; i <= end; i++) { + editor.TextViewMargin.RemoveCachedLine (i); + } + } editor.RedrawLines (start, end); } } diff --git a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/Document/TextDocument.cs b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/Document/TextDocument.cs index 749e05d94f..9f9b114e5c 100644 --- a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/Document/TextDocument.cs +++ b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/Document/TextDocument.cs @@ -1787,7 +1787,7 @@ namespace Mono.TextEditor textSegmentMarkerTree.Add (marker); var startLine = OffsetToLineNumber (marker.Offset); var endLine = OffsetToLineNumber (Math.Min (marker.EndOffset, Length)); - CommitMultipleLineUpdate (startLine, endLine); + CommitMultipleLineUpdate (startLine, endLine, marker is IChunkMarker); } /// <summary> @@ -1802,7 +1802,7 @@ namespace Mono.TextEditor var endLine = OffsetToLineNumber (Math.Min (marker.EndOffset, Length)); bool wasRemoved = textSegmentMarkerTree.Remove (marker); if (wasRemoved) { - CommitMultipleLineUpdate (startLine, endLine); + CommitMultipleLineUpdate (startLine, endLine, marker is IChunkMarker); } return wasRemoved; } @@ -1884,7 +1884,14 @@ namespace Mono.TextEditor RequestUpdate (new MultipleLineUpdate (start, end)); CommitDocumentUpdate (); } - + + // TODO: Merge with CommitMultipleLineUpdate (ABI break! + public void CommitMultipleLineUpdate (int start, int end, bool removeLineCache) + { + RequestUpdate (new MultipleLineUpdate (start, end) { RemoveLineCache = removeLineCache}); + CommitDocumentUpdate (); + } + public event EventHandler DocumentUpdated; #endregion diff --git a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextEditorData.cs b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextEditorData.cs index 1609832a40..48dfa4bf99 100644 --- a/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextEditorData.cs +++ b/main/src/core/Mono.TextEditor.Shared/Mono.TextEditor/TextEditorData.cs @@ -648,11 +648,7 @@ namespace Mono.TextEditor /// </summary> public void FixVirtualIndentation () { - if (!HasIndentationTracker || Options.IndentStyle != IndentStyle.Virtual) - return; - var line = Document.GetLine (Caret.Line); - if (line != null && line.Length > 0 && GetIndentationString (caret.Line - 1, int.MaxValue) == Document.GetTextAt (line.Offset, line.Length)) - Remove (line.Offset, line.Length); + FixVirtualIndentation (Caret.Line); } public void FixVirtualIndentation (int lineNumber) diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs index 5138ce0a7c..8283e41d7f 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/WorkspaceItem.cs @@ -423,7 +423,7 @@ namespace MonoDevelop.Projects public FilePath GetPreferencesDirectory () { - return BaseDirectory.Combine (".vs", Name, "xs"); + return FileName.ParentDirectory.Combine (".vs", Name, "xs"); } internal string GetPreferencesFileName () diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RoslynClassificationHighlighting.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RoslynClassificationHighlighting.cs index 0ea5b4ce24..f8f77d8804 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RoslynClassificationHighlighting.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor.Highlighting/RoslynClassificationHighlighting.cs @@ -167,7 +167,7 @@ namespace MonoDevelop.Ide.Editor.Highlighting continue; } if (start > lastClassifiedOffsetEnd) { - scopeStack = userScope; + scopeStack = defaultScope; ColoredSegment whitespaceSegment = new ColoredSegment (lastClassifiedOffsetEnd - offset, start - lastClassifiedOffsetEnd, scopeStack); coloredSegments.Add (whitespaceSegment); } @@ -179,7 +179,7 @@ namespace MonoDevelop.Ide.Editor.Highlighting } if (offset + length > lastClassifiedOffsetEnd) { - scopeStack = userScope; + scopeStack = defaultScope; ColoredSegment whitespaceSegment = new ColoredSegment (lastClassifiedOffsetEnd - offset, offset + length - lastClassifiedOffsetEnd, scopeStack); coloredSegments.Add (whitespaceSegment); } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditActions.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditActions.cs index ea6fe11b15..5dcee5b563 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditActions.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/EditActions.cs @@ -47,12 +47,12 @@ namespace MonoDevelop.Ide.Editor public static void MoveCaretRight (TextEditor editor) { - editor.EditorOperations.MoveToPreviousCharacter (false); + editor.EditorOperations.MoveToNextCharacter (false); } public static void MoveCaretLeft (TextEditor editor) { - editor.EditorOperations.MoveToNextCharacter (false); + editor.EditorOperations.MoveToPreviousCharacter (false); } public static void MoveCaretToLineEnd (TextEditor editor) diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/ITextSegmentMarker.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/ITextSegmentMarker.cs index 11f2442d0e..ad3ecbecc4 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/ITextSegmentMarker.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/ITextSegmentMarker.cs @@ -66,7 +66,12 @@ namespace MonoDevelop.Ide.Editor /// <summary> /// Just a simple underline /// </summary> - Underline + Underline, + + /// <summary> + /// Marks the background of the text as block + /// </summary> + Background } public interface IGenericTextSegmentMarker : ITextSegmentMarker diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs index c23b7820ff..eec1191845 100644 --- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs +++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/MonoDevelop.Projects.Formats.MSBuild/BuildEngine.v4.0.cs @@ -79,6 +79,10 @@ namespace MonoDevelop.Projects.MSBuild internal void UnloadProject (string file)
{ + lock (unsavedProjects) { + unsavedProjects.Remove (file); + } + RunSTA (delegate
{ // Unloading projects modifies the collection, so copy it @@ -87,10 +91,6 @@ namespace MonoDevelop.Projects.MSBuild if (loadedProjects.Length == 0) return; - lock (unsavedProjects) { - unsavedProjects.Remove (file); - } - var rootElement = loadedProjects[0].Xml; foreach (var p in loadedProjects) diff --git a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SmartIndentModeTests.cs b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SmartIndentModeTests.cs index 6fc9c9d6cd..d7ab43951c 100644 --- a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SmartIndentModeTests.cs +++ b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/SmartIndentModeTests.cs @@ -40,6 +40,7 @@ namespace Mono.TextEditor.Tests internal class TestIndentTracker : IndentationTracker { string indentString; + Dictionary<int, string> definedIndents = new Dictionary<int, string> (); public override IndentationTrackerFeatures SupportedFeatures { get { @@ -54,8 +55,15 @@ namespace Mono.TextEditor.Tests public override string GetIndentationString (int lineNumber) { + if (definedIndents.TryGetValue (lineNumber, out string result)) + return result; return indentString; } + + public void SetIndent(int lineNumber, string indentationString) + { + definedIndents [lineNumber] = indentationString; + } } TextEditorData CreateData (string content) diff --git a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs index 0398540887..2386abb1f2 100644 --- a/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs +++ b/main/src/core/MonoDevelop.TextEditor.Tests/Mono.TextEditor.Tests/VirtualIndentModeTests.cs @@ -568,6 +568,22 @@ namespace Mono.TextEditor.Tests Assert.AreEqual (new DocumentLocation (2, 6), data.Caret.Location); Assert.AreEqual ("\n\t\tFooBar", data.Document.Text); } + + /// <summary> + /// Virtual indentation handling broken #4489 + /// https://github.com/mono/monodevelop/issues/4489 + /// </summary> + [Test] + public void TestIssue4489 () + { + var data = CreateDataWithSpaces ("\n\t\t\n\n"); + var tracker = new SmartIndentModeTests.TestIndentTracker (); + tracker.SetIndent (1, " "); + data.IndentationTracker = tracker; + data.Caret.Location = new DocumentLocation (2, 2); + data.FixVirtualIndentation (); + Assert.AreEqual ("\n\n\n", data.Document.Text); + } } } |