diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2016-06-08 10:40:52 +0300 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2016-06-08 10:40:52 +0300 |
commit | d1c978e9b1744cb4a8bafe031b635df8a2b96370 (patch) | |
tree | b7e81779e3a34d27982219d72d4b089752ed2779 /main/src/core/Mono.Texteditor | |
parent | b7b6c7af09e1dcddfbe2de228d7b7068ced7a8b9 (diff) | |
parent | b58d8f63b01835cbbd3a1288ba12d79ce5737730 (diff) |
Merge branch 'master' into roslyn-previews
Diffstat (limited to 'main/src/core/Mono.Texteditor')
4 files changed, 69 insertions, 48 deletions
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs index 9b6f9cccee..13d37ef823 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Document/TextDocument.cs @@ -1060,6 +1060,7 @@ namespace Mono.TextEditor readonly object syncObject = new object(); CancellationTokenSource foldSegmentSrc; + object foldSegmentTaskLock = new object (); Task foldSegmentTask; public void UpdateFoldSegments (List<FoldSegment> newSegments, bool startTask = false, bool useApplicationInvoke = false, CancellationToken masterToken = default(CancellationToken)) @@ -1067,38 +1068,39 @@ namespace Mono.TextEditor if (newSegments == null) { return; } - - InterruptFoldWorker (); - bool update; - if (!startTask) { - var newFoldedSegments = UpdateFoldSegmentWorker (newSegments, out update); - if (useApplicationInvoke) { - Gtk.Application.Invoke (delegate { + lock (foldSegmentTaskLock) { + InterruptFoldWorker (); + bool update; + if (!startTask) { + var newFoldedSegments = UpdateFoldSegmentWorker (newSegments, out update); + if (useApplicationInvoke) { + Gtk.Application.Invoke (delegate { + foldedSegments = newFoldedSegments; + InformFoldTreeUpdated (); + }); + } else { foldedSegments = newFoldedSegments; InformFoldTreeUpdated (); - }); - } else { - foldedSegments = newFoldedSegments; - InformFoldTreeUpdated (); - } - return; - } - foldSegmentSrc = new CancellationTokenSource (); - masterToken.Register (InterruptFoldWorker); - var token = foldSegmentSrc.Token; - foldSegmentTask = Task.Factory.StartNew (delegate { - var segments = UpdateFoldSegmentWorker (newSegments, out update, token); - if (token.IsCancellationRequested) + } return; - Gtk.Application.Invoke (delegate { + } + foldSegmentSrc = new CancellationTokenSource (); + masterToken.Register (InterruptFoldWorker); + var token = foldSegmentSrc.Token; + foldSegmentTask = Task.Factory.StartNew (delegate { + var segments = UpdateFoldSegmentWorker (newSegments, out update, token); if (token.IsCancellationRequested) return; foldedSegments = segments; - InformFoldTreeUpdated (); - if (update) - CommitUpdateAll (); - }); - }, token); + Gtk.Application.Invoke (delegate { + if (token.IsCancellationRequested) + return; + InformFoldTreeUpdated (); + if (update) + CommitUpdateAll (); + }); + }, token); + } } void RemoveFolding (FoldSegment folding) @@ -1275,28 +1277,16 @@ namespace Mono.TextEditor public void EnsureOffsetIsUnfolded (int offset) { - bool needUpdate = false; foreach (FoldSegment fold in GetFoldingsFromOffset (offset).Where (f => f.IsFolded && f.Offset < offset && offset < f.EndOffset)) { - needUpdate = true; fold.IsFolded = false; } - if (needUpdate) { - RequestUpdate (new UpdateAll ()); - CommitDocumentUpdate (); - } } public void EnsureSegmentIsUnfolded (int offset, int length) { - bool needUpdate = false; foreach (var fold in GetFoldingContaining (offset, length).Where (f => f.IsFolded)) { - needUpdate = true; fold.IsFolded = false; } - if (needUpdate) { - RequestUpdate (new UpdateAll ()); - CommitDocumentUpdate (); - } } internal void InformFoldTreeUpdated () @@ -1308,13 +1298,30 @@ namespace Mono.TextEditor public event EventHandler FoldTreeUpdated; HashSet<FoldSegment> foldedSegments = new HashSet<FoldSegment> (); + public IEnumerable<FoldSegment> FoldedSegments { get { return foldedSegments; } } + internal void InformFoldChanged (FoldSegmentEventArgs args) { + lock (foldSegmentTaskLock) { + if (foldSegmentTask != null) { + foldSegmentTask.ContinueWith (delegate { + Gtk.Application.Invoke (delegate { + InternalInformFoldChanged (args); + }); + }); + } else { + InternalInformFoldChanged (args); + } + } + } + + void InternalInformFoldChanged (FoldSegmentEventArgs args) + { if (args.FoldSegment.IsFolded) { foldedSegments.Add (args.FoldSegment); } else { @@ -1324,7 +1331,7 @@ namespace Mono.TextEditor if (handler != null) handler (this, args); } - + public event EventHandler<FoldSegmentEventArgs> Folded; #endregion diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs index ca73502970..6d1ee3972b 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/Gui/TextViewMargin.cs @@ -2804,8 +2804,10 @@ namespace Mono.TextEditor } } else { double xPos = position; - if (line.Length == 0 && Caret.Column > 1) + if (line.Length == 0 && Caret.Column > 1) { + wrapper = GetLayout (line); DrawIndent (cr, wrapper, line, lx, y); + } DrawCaretLineMarker (cr, xPos, y, lineArea.X + lineArea.Width - xPos, _lineHeight); } } diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextLinkEditMode.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextLinkEditMode.cs index bc5fc1f175..3b9b2f7f4a 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextLinkEditMode.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextLinkEditMode.cs @@ -509,7 +509,7 @@ namespace Mono.TextEditor if (link.GetStringFunc != null) { link.Values = link.GetStringFunc (GetStringCallback); } - if (!link.IsEditable && link.Values.Count > 0) { + if (!link.IsEditable && link.Values != null && link.Values.Count > 0) { link.CurrentText = (string)link.Values [link.Values.Count - 1]; } else { if (!link.PrimaryLink.IsInvalid) { diff --git a/main/src/core/Mono.Texteditor/SyntaxModes/FSharpSyntaxMode.xml b/main/src/core/Mono.Texteditor/SyntaxModes/FSharpSyntaxMode.xml index 53bc2dda05..24bf17ca41 100644 --- a/main/src/core/Mono.Texteditor/SyntaxModes/FSharpSyntaxMode.xml +++ b/main/src/core/Mono.Texteditor/SyntaxModes/FSharpSyntaxMode.xml @@ -295,23 +295,35 @@ <Group color="User Types"/> </Match> - <Match expression="(let)(\s+)(static|abstract|default|override|public|extern|internal|mutable|rec|inline|private)(\s+)(static|abstract|default|override|public|extern|internal|mutable|rec|inline|private)(\s+)(\w+|``.*``)(?:\s[^=:])" ignorecase="False"> + <Match expression="(let\s+)(static|abstract|default|override|public|extern|internal|mutable|rec|inline|private)(\s+)(static|abstract|default|override|public|extern|internal|mutable|rec|inline|private)(\s+\w+)(?:\s[^=:])" ignorecase="False"> <!-- let inline add x y = x + y --> <Group color="Keyword(Iteration)"/> - <Group color="Plain Text" /> <Group color="Keyword(Modifiers)"/> <Group color="Plain Text" /> <Group color="Keyword(Modifiers)"/> - <Group color="Plain Text" /> <Group color="User Method Declaration"/> </Match> - <Match expression="(let)(\s+)(static|abstract|default|override|public|extern|internal|mutable|rec|inline|private)(\s+)(\w+|``[^`]*``)(?:\s+[^=:])" ignorecase="False"> - <!-- let inline add x y = x + y --> + <Match expression="(let\s+)(static|abstract|default|override|public|extern|internal|mutable|rec|inline|private)(\s+)(static|abstract|default|override|public|extern|internal|mutable|rec|inline|private)(\s+``[^`]*``)(?:\s[^=:])" ignorecase="False"> + <!-- let inline ``some id`` x y = x + y --> <Group color="Keyword(Iteration)"/> - <Group color="Plain Text" /> <Group color="Keyword(Modifiers)"/> <Group color="Plain Text" /> + <Group color="Keyword(Modifiers)"/> + <Group color="User Method Declaration"/> + </Match> + + <Match expression="(let\s+)(static|abstract|default|override|public|extern|internal|mutable|rec|inline|private)(\s+\w+)(?:\s+[^=:])" ignorecase="False"> + <!-- let inline add x y = x + y --> + <Group color="Keyword(Iteration)"/> + <Group color="Keyword(Modifiers)"/> + <Group color="User Method Declaration"/> + </Match> + + <Match expression="(let\s+)(static|abstract|default|override|public|extern|internal|mutable|rec|inline|private)(\s+``[^`]*``)(?:\s+[^=:])" ignorecase="False"> + <!-- let inline ``some id`` x y = x + y --> + <Group color="Keyword(Iteration)"/> + <Group color="Keyword(Modifiers)"/> <Group color="User Method Declaration"/> </Match> @@ -363,7 +375,7 @@ <Group color="Plain Text"/> </Match> - <Match expression="(module|type)(\s+)(\w+|``[^`]*``)" ignorecase="False"> + <Match expression="(module|type|and)(\s+)(\w+|``[^`]*``)" ignorecase="False"> <Group color="Keyword(Namespace)"/> <Group color="Plain Text"/> <Group color="User Types"/> |