diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-07-29 15:51:33 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-07-29 15:51:33 +0400 |
commit | f763e51a0b43d7c0a3594de4ae28731ee71ce5c1 (patch) | |
tree | b437c31e186b0976aa8fe164dd9539e114d98f94 /main | |
parent | 6c29cfe612f2d435bd93f480c3f130c04ebfa2cf (diff) |
Fixed text editor splitting bug.
Diffstat (limited to 'main')
-rw-r--r-- | main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs index 1ec16f0f08..29e8fcae6d 100644 --- a/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs +++ b/main/src/core/Mono.Texteditor/Mono.TextEditor/TextViewMargin.cs @@ -128,49 +128,55 @@ namespace Mono.TextEditor throw new ArgumentNullException ("textEditor"); this.textEditor = textEditor; - textEditor.Document.TextReplaced += delegate(object sender,ReplaceEventArgs e) { - RemoveCachedLine (Document.GetLineByOffset (e.Offset)); - if (mouseSelectionMode == MouseSelectionMode.Word && e.Offset < mouseWordStart) { - int delta = -e.Count; - if (!string.IsNullOrEmpty (e.Value)) - delta += e.Value.Length; - mouseWordStart += delta; - mouseWordEnd += delta; - } - }; + textEditor.Document.TextReplaced += HandleTextReplaced; base.cursor = xtermCursor; textEditor.HighlightSearchPatternChanged += delegate { selectedRegions.Clear (); RefreshSearchMarker (); }; - // textEditor.SelectionChanged += delegate { DisposeLayoutDict (); }; - textEditor.Document.TextReplaced += delegate(object sender, ReplaceEventArgs e) { - if (selectedRegions.Count == 0) - return; - List<ISegment> newRegions = new List<ISegment> (this.selectedRegions); - Document.UpdateSegments (newRegions, e); - this.selectedRegions = newRegions; - RefreshSearchMarker (); - }; textEditor.Document.LineChanged += TextEditorDocumentLineChanged; textEditor.GetTextEditorData ().SearchChanged += HandleSearchChanged; markerLayout = PangoUtil.CreateLayout (textEditor); - textEditor.Document.EndUndo += delegate { - if (!textEditor.Document.IsInAtomicUndo) - UpdateBracketHighlighting (this, EventArgs.Empty); - }; + textEditor.Document.EndUndo += HandleEndUndo; textEditor.SelectionChanged += UpdateBracketHighlighting; - textEditor.Document.Undone += delegate { - UpdateBracketHighlighting (this, EventArgs.Empty); - }; - textEditor.Document.Redone += delegate { - UpdateBracketHighlighting (this, EventArgs.Empty); - }; + textEditor.Document.Undone += HandleUndone; + textEditor.Document.Redone += HandleUndone; + Caret.PositionChanged += UpdateBracketHighlighting; textEditor.VScroll += HandleVAdjustmentValueChanged; } + void HandleUndone (object sender, EventArgs e) + { + UpdateBracketHighlighting (this, EventArgs.Empty); + } + + void HandleEndUndo (object sender, EventArgs e) + { + if (!textEditor.Document.IsInAtomicUndo) + UpdateBracketHighlighting (this, EventArgs.Empty); + } + + void HandleTextReplaced (object sender, ReplaceEventArgs e) + { + RemoveCachedLine (Document.GetLineByOffset (e.Offset)); + if (mouseSelectionMode == MouseSelectionMode.Word && e.Offset < mouseWordStart) { + int delta = -e.Count; + if (!string.IsNullOrEmpty (e.Value)) + delta += e.Value.Length; + mouseWordStart += delta; + mouseWordEnd += delta; + } + + if (selectedRegions.Count > 0) { + List<ISegment> newRegions = new List<ISegment> (this.selectedRegions); + Document.UpdateSegments (newRegions, e); + this.selectedRegions = newRegions; + RefreshSearchMarker (); + } + } + void TextEditorDocumentLineChanged (object sender, LineEventArgs e) { RemoveCachedLine (e.Line); @@ -531,7 +537,13 @@ namespace Mono.TextEditor StopCaretThread (); DisposeHighightBackgroundWorker (); DisposeSearchPatternWorker (); - + + textEditor.Document.TextReplaced -= HandleTextReplaced; + textEditor.Document.LineChanged -= TextEditorDocumentLineChanged; + textEditor.Document.EndUndo -= HandleEndUndo; + textEditor.Document.Undone -= HandleUndone; + textEditor.Document.Redone -= HandleUndone; + textEditor.Document.EndUndo -= UpdateBracketHighlighting; Caret.PositionChanged -= UpdateBracketHighlighting; |