From 96160bb80d374c6e8accb2dc9796f44f5bb8f3a8 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 16 May 2005 14:42:43 +0000 Subject: [PATCH] Breakpoints are now a special kind of bookmarks. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@143 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Pads/BreakPointsPad.cs | 35 +++++-- .../Src/Document/BookmarkManager/Bookmark.cs | 54 +++++++++-- .../BookmarkManager/BookmarkManager.cs | 59 ++++++++++-- .../FoldingStrategy/IndentFoldingStrategy.cs | 43 +++++---- .../Project/Src/Gui/IconBarMargin.cs | 44 ++++++--- .../Project/Src/Gui/TextView.cs | 10 +- .../Project/ICSharpCode.SharpDevelop.csproj | 33 +++++-- .../Workbench/Layouts/SdiWorkspaceLayout.cs | 2 + .../Src/Services/Debugger/DebugClasses.cs | 57 ++++++++--- .../Src/Services/Debugger/DebuggerService.cs | 96 ++++++++++--------- .../Src/TextEditor/Bookmarks/Bookmark.cs | 64 +++++-------- .../Bookmarks/BookmarkEventHandler.cs | 8 +- .../TextEditor/Bookmarks/BookmarkManager.cs | 34 +++---- .../Bookmarks/Commands/MenuCommands.cs | 2 +- .../TextEditor/Bookmarks/Pad/BookmarkPad.cs | 10 +- .../Pad/BookmarkPadToolbarCommands.cs | 2 +- .../Bookmarks/Pad/Nodes/BookmarkFolderNode.cs | 12 +-- .../Bookmarks/Pad/Nodes/BookmarkNode.cs | 8 +- .../Gui/Editor/SharpDevelopTextAreaControl.cs | 44 ++------- .../Gui/Editor/TextEditorDisplayBinding.cs | 6 +- 20 files changed, 377 insertions(+), 246 deletions(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs index 60b8087042..034e3aecbd 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs @@ -68,8 +68,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads { name.Text = "Name"; path.Text = "Path"; - - FillList(); + + FillList(); } void BreakpointsListItemCheck(object sender, ItemCheckEventArgs e) @@ -89,31 +89,46 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads breakpointsList.BeginUpdate(); breakpointsList.Items.Clear(); foreach(DebuggerLibrary.Breakpoint b in NDebugger.Instance.Breakpoints) { - AddBreakpoint(this, new BreakpointEventArgs(b)); + AddBreakpoint(new BreakpointEventArgs(b)); } breakpointsList.EndUpdate(); breakpointsList.ItemCheck += new ItemCheckEventHandler(BreakpointsListItemCheck); } void AddBreakpoint(object sender, BreakpointEventArgs e) + { + breakpointsList.ItemCheck -= new ItemCheckEventHandler(BreakpointsListItemCheck); + AddBreakpoint(e); + breakpointsList.ItemCheck += new ItemCheckEventHandler(BreakpointsListItemCheck); + } + + void AddBreakpoint(BreakpointEventArgs e) { ListViewItem item = new ListViewItem(); - item.Tag = e.Breakpoint; + item.Tag = e.Breakpoint; breakpointsList.Items.Add(item); - RefreshBreakpoint(this, e); + RefreshBreakpoint(item, e); } void RefreshBreakpoint(object sender, BreakpointEventArgs e) { + breakpointsList.ItemCheck -= new ItemCheckEventHandler(BreakpointsListItemCheck); foreach (ListViewItem item in breakpointsList.Items) { if (e.Breakpoint == item.Tag) { - item.SubItems.Clear(); - item.Checked = e.Breakpoint.Enabled; - item.Text = Path.GetFileName(e.Breakpoint.SourcecodeSegment.SourceFullFilename) + ", Line = " + e.Breakpoint.SourcecodeSegment.StartLine.ToString(); - item.ForeColor = e.Breakpoint.HadBeenSet ? Color.Black : Color.Gray; - item.SubItems.AddRange(new string[] {Path.GetDirectoryName(e.Breakpoint.SourcecodeSegment.SourceFullFilename)}); + RefreshBreakpoint(item, e); + break; } } + breakpointsList.ItemCheck += new ItemCheckEventHandler(BreakpointsListItemCheck); + } + + void RefreshBreakpoint(ListViewItem item, BreakpointEventArgs e) + { + item.SubItems.Clear(); + item.Checked = e.Breakpoint.Enabled; + item.Text = Path.GetFileName(e.Breakpoint.SourcecodeSegment.SourceFullFilename) + ", Line = " + e.Breakpoint.SourcecodeSegment.StartLine.ToString(); + item.ForeColor = e.Breakpoint.HadBeenSet ? Color.Black : Color.Gray; + item.SubItems.AddRange(new string[] { Path.GetDirectoryName(e.Breakpoint.SourcecodeSegment.SourceFullFilename) }); } void RemoveBreakpoint(object sender, BreakpointEventArgs e) diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/Bookmark.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/Bookmark.cs index 65975e9f0f..933987fb65 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/Bookmark.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/Bookmark.cs @@ -1,13 +1,13 @@ -/* - * Created by SharpDevelop. - * User: Omnibrain - * Date: 26.12.2004 - * Time: 19:25 - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ +// +// +// +// +// +// using System; +using System.Drawing; +using SWF = System.Windows.Forms; namespace ICSharpCode.TextEditor.Document { @@ -24,6 +24,9 @@ namespace ICSharpCode.TextEditor.Document get { return document; } + set { + document = value; + } } public bool IsEnabled { @@ -42,7 +45,28 @@ namespace ICSharpCode.TextEditor.Document return lineNumber; } set { - lineNumber = value; + if (lineNumber != value) { + lineNumber = value; + OnLineNumberChanged(EventArgs.Empty); + } + } + } + + public event EventHandler LineNumberChanged; + + protected virtual void OnLineNumberChanged(EventArgs e) + { + if (LineNumberChanged != null) { + LineNumberChanged(this, e); + } + } + + /// + /// Gets if the bookmark can be toggled off using the 'set/unset bookmark' command. + /// + public virtual bool CanToggle { + get { + return true; } } @@ -56,5 +80,17 @@ namespace ICSharpCode.TextEditor.Document this.lineNumber = lineNumber; this.isEnabled = isEnabled; } + + public virtual void Click(SWF.MouseButtons mouseButtons) + { + if (mouseButtons == SWF.MouseButtons.Left) { + document.BookmarkManager.RemoveMark(this); + } + } + + public virtual void Draw(IconBarMargin margin, Graphics g, Point p) + { + margin.DrawBookmark(g, p.Y, isEnabled); + } } } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManager.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManager.cs index 9d6517bc00..4ea1fe075c 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManager.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/BookmarkManager/BookmarkManager.cs @@ -10,6 +10,11 @@ using System.Collections.Generic; namespace ICSharpCode.TextEditor.Document { + public interface IBookmarkFactory + { + Bookmark CreateBookmark(IDocument document, int lineNumber); + } + /// /// This class handles the bookmarks for a buffer /// @@ -26,7 +31,13 @@ namespace ICSharpCode.TextEditor.Document return bookmark; } } - + + public IDocument Document { + get { + return document; + } + } + /// /// Creates a new instance of /// @@ -36,27 +47,56 @@ namespace ICSharpCode.TextEditor.Document lineTracker.LineCountChanged += new LineManagerEventHandler(MoveIndices); } - /// + IBookmarkFactory factory; + + public IBookmarkFactory Factory { + get { + return factory; + } + set { + factory = value; + } + } + + /// /// Sets the mark at the line lineNr if it is not set, if the /// line is already marked the mark is cleared. - /// + /// public void ToggleMarkAt(int lineNr) { for (int i = 0; i < bookmark.Count; ++i) { - if (bookmark[i].LineNumber == lineNr) { - Bookmark mark = bookmark[i]; + Bookmark mark = bookmark[i]; + if (mark.LineNumber == lineNr && mark.CanToggle) { bookmark.RemoveAt(i); OnRemoved(new BookmarkEventArgs(mark)); OnChanged(EventArgs.Empty); return; } } - Bookmark newMark = new Bookmark(document, lineNr); + Bookmark newMark; + if (factory != null) + newMark = factory.CreateBookmark(document, lineNr); + else + newMark = new Bookmark(document, lineNr); bookmark.Add(newMark); OnAdded(new BookmarkEventArgs(newMark)); OnChanged(EventArgs.Empty); } + public void AddMark(Bookmark mark) + { + bookmark.Add(mark); + OnAdded(new BookmarkEventArgs(mark)); + OnChanged(EventArgs.Empty); + } + + public void RemoveMark(Bookmark mark) + { + bookmark.Remove(mark); + OnRemoved(new BookmarkEventArgs(mark)); + OnChanged(EventArgs.Empty); + } + /// /// true, if a mark at mark exists, otherwise false /// @@ -81,6 +121,7 @@ namespace ICSharpCode.TextEditor.Document Bookmark mark = bookmark[i]; if (e.LinesMoved < 0 && mark.LineNumber == e.LineStart) { bookmark.RemoveAt(i); + OnRemoved(new BookmarkEventArgs(mark)); --i; changed = true; } else if (mark.LineNumber > e.LineStart + 1 || (e.LinesMoved < 0 && mark.LineNumber > e.LineStart)) { @@ -189,7 +230,7 @@ namespace ICSharpCode.TextEditor.Document return prev; } - protected virtual void OnChanged(EventArgs e) + protected virtual void OnChanged(EventArgs e) { if (Changed != null) { Changed(this, e); @@ -197,7 +238,7 @@ namespace ICSharpCode.TextEditor.Document } - protected virtual void OnRemoved(BookmarkEventArgs e) + protected virtual void OnRemoved(BookmarkEventArgs e) { if (Removed != null) { Removed(this, e); @@ -205,7 +246,7 @@ namespace ICSharpCode.TextEditor.Document } - protected virtual void OnAdded(BookmarkEventArgs e) + protected virtual void OnAdded(BookmarkEventArgs e) { if (Added != null) { Added(this, e); diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/IndentFoldingStrategy.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/IndentFoldingStrategy.cs index 5c7e98e4ac..f7b91578d3 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/IndentFoldingStrategy.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/FoldingStrategy/IndentFoldingStrategy.cs @@ -1,36 +1,47 @@ // // // -// +// // // using System; -using System.Drawing; -using System.Collections; +using System.Collections.Generic; namespace ICSharpCode.TextEditor.Document { - /* /// /// A simple folding strategy which calculates the folding level /// using the indent level of the line. /// public class IndentFoldingStrategy : IFoldingStrategy { - /// - /// Calculates the fold level of a specific line. - /// - public int CalculateFoldLevel(IDocument document, int lineNumber) + public List GenerateFoldMarkers(IDocument document, string fileName, object parseInformation) { - LineSegment line = document.GetLineSegment(lineNumber); - int foldLevel = 0; - - while (document.GetCharAt(line.Offset + foldLevel) == '\t' && foldLevel + 1 < line.TotalLength) { - ++foldLevel; + List l = new List(); + Stack offsetStack = new Stack(); + Stack textStack = new Stack(); + //int level = 0; + //foreach (LineSegment segment in document.LineSegmentCollection) { + // + //} + return l; + } + + int GetLevel(IDocument document, int offset) + { + int level = 0; + int spaces = 0; + for (int i = offset; i < document.TextLength; ++i) { + char c = document.GetCharAt(i); + if (c == '\t' || (c == ' ' && ++spaces == 4)) { + spaces = 0; + ++level; + } else { + break; + } } - - return foldLevel; + return level; } - }*/ + } } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/IconBarMargin.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/IconBarMargin.cs index 9e10a9d7d8..9ed803d719 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/IconBarMargin.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/IconBarMargin.cs @@ -1,13 +1,13 @@ // // // -// +// // // using System; using System.Windows.Forms; -using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; @@ -53,20 +53,40 @@ namespace ICSharpCode.TextEditor int lineNumber = textArea.Document.GetVisibleLine(mark.LineNumber); int yPos = (int)(lineNumber * textArea.TextView.FontHeight) - textArea.VirtualTop.Y; if (yPos >= rect.Y && yPos <= rect.Bottom) { - DrawBookmark(g, yPos, mark.IsEnabled); + //DrawBookmark(g, yPos, mark.IsEnabled); + mark.Draw(this, g, new Point(0, yPos)); } } base.Paint(g, rect); } -#region Drawing functions + public override void HandleMouseDown(Point mousePos, MouseButtons mouseButtons) + { + List marks = textArea.Document.BookmarkManager.Marks; + int oldCount = marks.Count; + foreach (Bookmark mark in marks) { + int lineNumber = textArea.Document.GetVisibleLine(mark.LineNumber); + int fontHeight = textArea.TextView.FontHeight; + int yPos = lineNumber * fontHeight - textArea.VirtualTop.Y; + if (mousePos.Y > yPos && mousePos.Y < yPos + fontHeight) { + mark.Click(mouseButtons); + if (oldCount != marks.Count) { + textArea.UpdateLine(lineNumber); + } + return; + } + } + base.HandleMouseDown(mousePos, mouseButtons); + } + + #region Drawing functions public void DrawBreakpoint(Graphics g, int y, bool isEnabled) { int delta = 1; int radius = Math.Min(Size.Width, textArea.TextView.FontHeight); Rectangle rect = new Rectangle(delta, y, - radius, + radius, radius); @@ -96,7 +116,7 @@ namespace ICSharpCode.TextEditor Rectangle rect = new Rectangle(1, y + delta, base.drawingPosition.Width - 4, textArea.TextView.FontHeight - delta * 2); if (isEnabled) { - using (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top), + using (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top), new Point(rect.Right, rect.Bottom), Color.SkyBlue, Color.White)) { @@ -105,7 +125,7 @@ namespace ICSharpCode.TextEditor } else { FillRoundRect(g, Brushes.White, rect); } - using (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top), + using (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top), new Point(rect.Right, rect.Bottom), Color.SkyBlue, Color.Blue)) { @@ -119,19 +139,19 @@ namespace ICSharpCode.TextEditor { int delta = textArea.TextView.FontHeight / 8; Rectangle rect = new Rectangle(1, y + delta, base.drawingPosition.Width - 4, textArea.TextView.FontHeight - delta * 2); - using (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top), + using (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top), new Point(rect.Right, rect.Bottom), Color.LightYellow, Color.Yellow)) { FillArrow(g, brush, rect); } - using (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top), + using (Brush brush = new LinearGradientBrush(new Point(rect.Left, rect.Top), new Point(rect.Right, rect.Bottom), Color.Yellow, Color.Brown)) { using (Pen pen = new Pen(brush)) { - DrawArrow(g, pen, rect); + DrawArrow(g, pen, rect); } } } @@ -141,7 +161,7 @@ namespace ICSharpCode.TextEditor GraphicsPath gp = new GraphicsPath(); int halfX = r.Width / 2; int halfY = r.Height/ 2; - gp.AddLine(r.X, r.Y + halfY/2, r.X + halfX, r.Y + halfY/2); + gp.AddLine(r.X, r.Y + halfY/2, r.X + halfX, r.Y + halfY/2); gp.AddLine(r.X + halfX, r.Y + halfY/2, r.X + halfX, r.Y); gp.AddLine(r.X + halfX, r.Y, r.Right, r.Y + halfY); gp.AddLine(r.Right, r.Y + halfY, r.X + halfX, r.Bottom); @@ -200,6 +220,6 @@ namespace ICSharpCode.TextEditor } } -#endregion + #endregion } } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs index 3101494ed4..33bf4ac9de 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs @@ -110,9 +110,15 @@ namespace ICSharpCode.TextEditor OptionsChanged(); } + static int GetFontHeight(Font font) + { + int h = font.Height; + return (h < 16) ? h + 1 : h; + } + public void OptionsChanged() { - this.fontHeight = TextEditorProperties.Font.Height; + this.fontHeight = GetFontHeight(TextEditorProperties.Font); if (this.charWitdh != null) { this.charWitdh.Clear(); } @@ -126,7 +132,7 @@ namespace ICSharpCode.TextEditor } // Just to ensure that fontHeight and char widths are always correct... - if (fontHeight != TextEditorProperties.Font.Height) { + if (fontHeight != GetFontHeight(TextEditorProperties.Font)) { OptionsChanged(); base.TextArea.Refresh(); return; diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 2c8779b7e2..6b33b6e207 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -198,7 +198,7 @@ Form - Form + UserControl Form @@ -266,7 +266,7 @@ Form - Component + UserControl @@ -623,7 +623,9 @@ - + + UserControl + @@ -632,11 +634,21 @@ - - - - - + + UserControl + + + UserControl + + + UserControl + + + UserControl + + + UserControl + @@ -647,7 +659,9 @@ - + + Component + @@ -666,7 +680,6 @@ {35cef10f-2d4c-45f2-9dd1-161e0fec583c} ICSharpCode.Core - \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs index 8b565332f6..b4a069ab89 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs @@ -319,6 +319,8 @@ namespace ICSharpCode.SharpDevelop.Gui public PadContentWrapper(PadDescriptor padDescriptor) { + if (padDescriptor == null) + throw new ArgumentNullException("padDescriptor"); this.padDescriptor = padDescriptor; this.DockableAreas = ((((WeifenLuo.WinFormsUI.DockAreas.Float | WeifenLuo.WinFormsUI.DockAreas.DockLeft) | WeifenLuo.WinFormsUI.DockAreas.DockRight) | diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebugClasses.cs b/src/Main/Base/Project/Src/Services/Debugger/DebugClasses.cs index fe14641606..20d7d51dc2 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebugClasses.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebugClasses.cs @@ -1,7 +1,7 @@ // // // -// +// // // @@ -12,34 +12,43 @@ using System.CodeDom.Compiler; using System.Collections; using System.IO; using System.Diagnostics; +using ICSharpCode.SharpDevelop.Bookmarks; namespace ICSharpCode.Core { - public class Breakpoint + public class Breakpoint { - string fileName; - int lineNumber; + BreakpointBookmark bookmark; object tag; - bool isEnabled = true; + public BreakpointBookmark Bookmark { + get { + return bookmark; + } + } public string FileName { get { - return fileName; + return bookmark.FileName; } set { - fileName = value; + bookmark.FileName = value; } } public int LineNumber { get { - return lineNumber; + return bookmark.LineNumber + 1; } set { - lineNumber = value; + bookmark.LineNumber = value - 1; } } + + public event EventHandler LineNumberChanged { + add { bookmark.LineNumberChanged += value; } + remove { bookmark.LineNumberChanged -= value; } + } public object Tag { get { @@ -52,17 +61,37 @@ namespace ICSharpCode.Core public bool IsEnabled { get { - return isEnabled; + return bookmark.IsEnabled; } set { - isEnabled = value; + bookmark.IsEnabled = value; + } + } + + public Breakpoint(ICSharpCode.TextEditor.Document.IDocument document, string fileName, int lineNumber) + { + bookmark = new BreakpointBookmark(this, fileName, document, lineNumber - 1); + } + } + + public class BreakpointBookmark : SDBookmark + { + Breakpoint breakpoint; + + public Breakpoint Breakpoint { + get { + return breakpoint; } } - public Breakpoint(string fileName, int lineNumber) + public BreakpointBookmark(Breakpoint breakpoint, string fileName, ICSharpCode.TextEditor.Document.IDocument document, int lineNumber) : base(fileName, document, lineNumber) + { + this.breakpoint = breakpoint; + } + + public override void Draw(ICSharpCode.TextEditor.IconBarMargin margin, Graphics g, Point p) { - this.fileName = fileName; - this.lineNumber = lineNumber; + margin.DrawBreakpoint(g, p.Y, IsEnabled); } } diff --git a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs index 42998630ab..632c5614f7 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs @@ -20,6 +20,7 @@ using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor; using System.Drawing; using System.Windows.Forms; +using BM = ICSharpCode.SharpDevelop.Bookmarks; namespace ICSharpCode.Core { @@ -344,25 +345,6 @@ namespace ICSharpCode.Core } } - public static void ToggleBreakpointAt(string fileName, int line, int column) - { - foreach(Breakpoint b in breakpoints) { - if (b.FileName == fileName && b.LineNumber == line) { - breakpoints.Remove(b); - OnBreakPointRemoved(EventArgs.Empty); - return; - } - } - breakpoints.Add(new Breakpoint(fileName, line)); - OnBreakPointAdded(EventArgs.Empty); - } - - - - - - - class BreakpointMarker: TextMarker { public BreakpointMarker(int offset, int length, TextMarkerType textMarkerType, Color color, Color foreColor):base(offset, length, textMarkerType, color, foreColor) @@ -380,6 +362,28 @@ namespace ICSharpCode.Core public static void InitializeService2() { WorkbenchSingleton.WorkbenchCreated += new EventHandler(WorkspaceCreated); + BM.BookmarkManager.Added += BookmarkAdded; + BM.BookmarkManager.Removed += BookmarkRemoved; + } + + static void BookmarkAdded(object sender, BM.BookmarkEventArgs e) + { + BreakpointBookmark bb = e.Bookmark as BreakpointBookmark; + if (bb != null) { + breakpoints.Add(bb.Breakpoint); + RefreshBreakpointMarkersInDocument(bb.Document); + OnBreakPointAdded(EventArgs.Empty); + } + } + + static void BookmarkRemoved(object sender, BM.BookmarkEventArgs e) + { + BreakpointBookmark bb = e.Bookmark as BreakpointBookmark; + if (bb != null) { + breakpoints.Remove(bb.Breakpoint); + RefreshBreakpointMarkersInDocument(bb.Document); + OnBreakPointRemoved(EventArgs.Empty); + } } static void WorkspaceCreated(object sender, EventArgs args) @@ -397,7 +401,7 @@ namespace ICSharpCode.Core textArea.IconBarMargin.Painted += new MarginPaintEventHandler(PaintIconBar); textArea.MouseMove += new MouseEventHandler(TextAreaMouseMove); - RefreshBreakpointMarkersInEditor(textArea.MotherTextEditorControl); + RefreshBreakpointMarkersInDocument(textArea.MotherTextEditorControl.Document); } } @@ -453,25 +457,35 @@ namespace ICSharpCode.Core } } - - static void IconBarMouseDown(AbstractMargin iconBar, Point mousepos, MouseButtons mouseButtons) { Rectangle viewRect = iconBar.TextArea.TextView.DrawingPosition; Point logicPos = iconBar.TextArea.TextView.GetLogicalPosition(0, mousepos.Y - viewRect.Top); if (logicPos.Y >= 0 && logicPos.Y < iconBar.TextArea.Document.TotalNumberOfLines) { - ToggleBreakpointAt(iconBar.TextArea.MotherTextEditorControl.FileName , logicPos.Y + 1, 0); - RefreshBreakpointMarkersInEditor(iconBar.TextArea.MotherTextEditorControl); + ToggleBreakpointAt(iconBar.TextArea.Document, iconBar.TextArea.MotherTextEditorControl.FileName, logicPos.Y + 1); iconBar.TextArea.Refresh(iconBar); } } + static void ToggleBreakpointAt(IDocument document, string fileName, int lineNumber) + { + foreach (Bookmark m in document.BookmarkManager.Marks) { + BreakpointBookmark bb = m as BreakpointBookmark; + if (bb != null) { + if (bb.Breakpoint.LineNumber == lineNumber) { + document.BookmarkManager.RemoveMark(m); + return; + } + } + } + document.BookmarkManager.AddMark(new Breakpoint(document, fileName, lineNumber).Bookmark); + } - static void RefreshBreakpointMarkersInEditor(TextEditorControl textEditor) + static void RefreshBreakpointMarkersInDocument(IDocument document) { - IDocument document = textEditor.Document; - System.Collections.Generic.List markers = textEditor.Document.MarkerStrategy.TextMarker; + if (document == null) return; + List markers = document.MarkerStrategy.TextMarker; // Remove all breakpoint markers for (int i = 0; i < markers.Count;) { if (markers[i] is BreakpointMarker) { @@ -481,10 +495,10 @@ namespace ICSharpCode.Core } } // Add breakpoint markers - foreach (Breakpoint b in Breakpoints) { - if (b.FileName.ToLower() == textEditor.FileName.ToLower()) { - LineSegment lineSeg = document.GetLineSegment((int)b.LineNumber - 1); - document.MarkerStrategy.TextMarker.Add(new BreakpointMarker(lineSeg.Offset, lineSeg.Length , TextMarkerType.SolidBlock, Color.Red, Color.White)); + foreach (Bookmark b in document.BookmarkManager.Marks) { + if (b is BreakpointBookmark) { + LineSegment lineSeg = document.GetLineSegment(b.LineNumber); + document.MarkerStrategy.TextMarker.Add(new BreakpointMarker(lineSeg.Offset, lineSeg.Length, TextMarkerType.SolidBlock, Color.Red, Color.White)); } } // Perform editor update @@ -497,16 +511,6 @@ namespace ICSharpCode.Core /// static void PaintIconBar(AbstractMargin iconBar, Graphics g, Rectangle rect) { - foreach (Breakpoint breakpoint in Breakpoints) { - if (Path.GetFullPath(breakpoint.FileName) == Path.GetFullPath(iconBar.TextArea.MotherTextEditorControl.FileName)) { - int lineNumber = iconBar.TextArea.Document.GetVisibleLine((int)breakpoint.LineNumber - 1); - int yPos = (int)(lineNumber * iconBar.TextArea.TextView.FontHeight) - iconBar.TextArea.VirtualTop.Y; - if (yPos >= rect.Y && yPos <= rect.Bottom) { - ((IconBarMargin)iconBar).DrawBreakpoint(g, yPos, breakpoint.IsEnabled); - } - } - } - foreach (TextMarker textMarker in iconBar.TextArea.Document.MarkerStrategy.TextMarker) { CurrentLineMarker currentLineMarker = textMarker as CurrentLineMarker; if (currentLineMarker != null) { @@ -556,11 +560,12 @@ namespace ICSharpCode.Core // otherwise textArea will close the tooltip. } else { // Look if it is variable - //value = selectedThread.LocalVariables[expresion].Value.ToString(); ResolveResult result = ParserService.Resolve(expression, logicPos.Y + 1, xPosition + 1, textArea.MotherTextEditorControl.FileName, textContent); string value = GetText(result); if (value != null) { + #if DEBUG value = "expr: >" + expression + "<\n" + value; + #endif textArea.SetToolTip(value); } oldToolTip = value; @@ -609,10 +614,9 @@ namespace ICSharpCode.Core } else if (result is TypeResolveResult) { return GetText(ambience, ((TypeResolveResult)result).ResolvedClass); } else { - if (result.ResolvedType == null) - return null; - else - return "expression of type " + ambience.Convert(result.ResolvedType); +// if (result.ResolvedType != null) +// return "expression of type " + ambience.Convert(result.ResolvedType); + return null; } } diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs index 87cffa7cd8..47ba7afba2 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Bookmark.cs @@ -8,41 +8,21 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Windows.Forms; using System.Drawing; -using System.CodeDom.Compiler; -using System.IO; -using System.Diagnostics; +using System.Text; using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.Gui.OptionPanels; -using ICSharpCode.SharpDevelop.Project; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.SharpDevelop.DefaultEditor.Commands; +using ICSharpCode.TextEditor; +using ICSharpCode.TextEditor.Document; -namespace Bookmark +namespace ICSharpCode.SharpDevelop.Bookmarks { /// /// Description of Bookmark. /// - public class Bookmark + public class SDBookmark : Bookmark { - ICSharpCode.TextEditor.Document.Bookmark bookmark; string fileName; - public ICSharpCode.TextEditor.Document.IDocument Document { - get { - return bookmark.Document; - } - } - - public ICSharpCode.TextEditor.Document.Bookmark CreateBookmark(ICSharpCode.TextEditor.Document.IDocument document) - { - this.bookmark = new ICSharpCode.TextEditor.Document.Bookmark(document, LineNumber, IsEnabled); - return bookmark; - } - public string FileName { get { return fileName; @@ -52,25 +32,33 @@ namespace Bookmark } } - public int LineNumber { - get { - return bookmark.LineNumber; - } + public SDBookmark(string fileName, IDocument document, int lineNumber) : base(document, lineNumber) + { + this.fileName = fileName; } + } + + public class SDBookmarkFactory : IBookmarkFactory + { + string fileName; + ICSharpCode.TextEditor.Document.BookmarkManager manager; - public bool IsEnabled { - get { - return bookmark.IsEnabled; - } - set { - bookmark.IsEnabled = value; + public SDBookmarkFactory(ICSharpCode.TextEditor.Document.BookmarkManager manager) + { + this.manager = manager; + } + + public void ChangeFilename(string newFileName) + { + fileName = newFileName; + foreach (SDBookmark mark in manager.Marks) { + mark.FileName = newFileName; } } - public Bookmark(string fileName, ICSharpCode.TextEditor.Document.Bookmark bookmark) + public Bookmark CreateBookmark(IDocument document, int lineNumber) { - this.fileName = fileName; - this.bookmark = bookmark; + return new SDBookmark(fileName, document, lineNumber); } } } diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkEventHandler.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkEventHandler.cs index 910730ccd4..cab58e43a1 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkEventHandler.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkEventHandler.cs @@ -9,7 +9,7 @@ using System; -namespace Bookmark +namespace ICSharpCode.SharpDevelop.Bookmarks { public delegate void BookmarkEventHandler(object sender, BookmarkEventArgs e); @@ -18,15 +18,15 @@ namespace Bookmark /// public class BookmarkEventArgs : EventArgs { - Bookmark bookmark; + SDBookmark bookmark; - public Bookmark Bookmark { + public SDBookmark Bookmark { get { return bookmark; } } - public BookmarkEventArgs(Bookmark bookmark) + public BookmarkEventArgs(SDBookmark bookmark) { this.bookmark = bookmark; } diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs index a9002ca068..a138e04d41 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkManager.cs @@ -1,27 +1,29 @@ using System; using System.Collections.Generic; using ICSharpCode.Core; +using ICSharpCode.TextEditor.Document; -namespace Bookmark +namespace ICSharpCode.SharpDevelop.Bookmarks { /// /// Description of BookmarkManager. /// public static class BookmarkManager { - static List bookmarks = new List(); + static List bookmarks = new List(); - public static List Bookmarks { + public static List Bookmarks { get { return bookmarks; } } - public static List GetBookmarks(string fileName) + public static List GetBookmarks(string fileName) { - List marks = new List(); + List marks = new List(); - foreach (Bookmark mark in bookmarks) { + foreach (SDBookmark mark in bookmarks) { + if (mark.FileName == null) continue; if (FileUtility.IsEqualFile(mark.FileName, fileName)) { marks.Add(mark); } @@ -30,23 +32,17 @@ namespace Bookmark return marks; } - public static void AddMark(string fileName, ICSharpCode.TextEditor.Document.Bookmark bookmark) + public static void AddMark(SDBookmark bookmark) { - Bookmark mark = new Bookmark(fileName, bookmark); - bookmarks.Add(mark); - OnAdded(new BookmarkEventArgs(mark)); + if (bookmarks.Contains(bookmark)) return; + bookmarks.Add(bookmark); + OnAdded(new BookmarkEventArgs(bookmark)); } - public static void RemoveMark(string fileName, ICSharpCode.TextEditor.Document.Bookmark bookmark) + public static void RemoveMark(SDBookmark bookmark) { - for (int i = 0; i < bookmarks.Count; ) { - if (FileUtility.IsEqualFile(bookmarks[i].FileName, fileName) && bookmarks[i].LineNumber == bookmark.LineNumber) { - OnRemoved(new BookmarkEventArgs(bookmarks[i])); - bookmarks.RemoveAt(i); - } else { - ++i; - } - } + bookmarks.Remove(bookmark); + OnRemoved(new BookmarkEventArgs(bookmark)); } static void OnRemoved(BookmarkEventArgs e) diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Commands/MenuCommands.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Commands/MenuCommands.cs index 8d458d5c99..852744f50d 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Commands/MenuCommands.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Commands/MenuCommands.cs @@ -25,7 +25,7 @@ using ICSharpCode.TextEditor; using ICSharpCode.TextEditor.Actions; using ICSharpCode.SharpDevelop.DefaultEditor.Commands; -namespace Bookmarks +namespace ICSharpCode.SharpDevelop.Bookmarks { public class ToggleBookmark : AbstractEditActionMenuCommand { diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs index 467141ef0c..56353412c9 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPad.cs @@ -21,7 +21,7 @@ using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.DefaultEditor.Commands; -namespace Bookmark +namespace ICSharpCode.SharpDevelop.Bookmarks { public class BookmarkPad : AbstractPadContent { @@ -62,12 +62,12 @@ namespace Bookmark BookmarkManager.Added += new BookmarkEventHandler(BookmarkManagerAdded); BookmarkManager.Removed += new BookmarkEventHandler(BookmarkManagerRemoved); - foreach (Bookmark mark in BookmarkManager.Bookmarks) { + foreach (SDBookmark mark in BookmarkManager.Bookmarks) { AddMark(mark); } } - void AddMark(Bookmark mark) + void AddMark(SDBookmark mark) { if (!fileNodes.ContainsKey(mark.FileName)) { BookmarkFolderNode folderNode = new BookmarkFolderNode(mark.FileName); @@ -80,7 +80,7 @@ namespace Bookmark void BookmarkManagerAdded(object sender, BookmarkEventArgs e) { - AddMark(e.Bookmark); + AddMark((SDBookmark)e.Bookmark); } void BookmarkManagerRemoved(object sender, BookmarkEventArgs e) @@ -98,7 +98,7 @@ namespace Bookmark { TreeNode node = bookmarkTreeView.SelectedNode; if (node != null) { - Bookmark mark = node.Tag as Bookmark; + SDBookmark mark = node.Tag as SDBookmark; if (mark != null) { FileService.JumpToFilePosition(mark.FileName, mark.LineNumber, 0); } diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPadToolbarCommands.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPadToolbarCommands.cs index 4083cba77a..096db44211 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPadToolbarCommands.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/BookmarkPadToolbarCommands.cs @@ -22,7 +22,7 @@ using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.DefaultEditor.Commands; using ICSharpCode.SharpDevelop; -namespace Bookmark +namespace ICSharpCode.SharpDevelop.Bookmarks { public class GotoNext : AbstractMenuCommand { diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkFolderNode.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkFolderNode.cs index 696a34ecd8..6e19471136 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkFolderNode.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkFolderNode.cs @@ -6,19 +6,19 @@ using ICSharpCode.TextEditor.Document; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; -namespace Bookmark +namespace ICSharpCode.SharpDevelop.Bookmarks { /// /// Description of SearchFolderNode. /// public class BookmarkFolderNode : ExtFolderNode { - List marks = new List(); + List marks = new List(); string fileName; string occurences; Image icon; - public List Marks { + public List Marks { get { return marks; } @@ -64,7 +64,7 @@ namespace Bookmark DrawText(g, occurences, Brushes.Gray, ItalicFont, ref x, e.Bounds.Y); } - public void AddMark(Bookmark mark) + public void AddMark(SDBookmark mark) { marks.Add(mark); @@ -76,7 +76,7 @@ namespace Bookmark SetText(); } - public void RemoveMark(Bookmark mark) + public void RemoveMark(SDBookmark mark) { marks.Remove(mark); if (isInitialized) { @@ -98,7 +98,7 @@ namespace Bookmark if (document.HighlightingStrategy == null) { document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(fileName); } - foreach (Bookmark mark in marks) { + foreach (SDBookmark mark in marks) { TreeNode newResult = new BookmarkNode(mark); Nodes.Add(newResult); } diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs index 99f3ed4982..4b2e7293ea 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/Pad/Nodes/BookmarkNode.cs @@ -7,14 +7,14 @@ using ICSharpCode.TextEditor; using ICSharpCode.TextEditor.Document; using ICSharpCode.SharpDevelop.Gui; -namespace Bookmark +namespace ICSharpCode.SharpDevelop.Bookmarks { /// /// Description of SearchFolderNode. /// public class BookmarkNode : ExtTreeNode { - Bookmark bookmark; + SDBookmark bookmark; SizeF spaceSize; static StringFormat sf = (StringFormat)System.Drawing.StringFormat.GenericTypographic.Clone(); @@ -23,13 +23,13 @@ namespace Bookmark string positionText; - public Bookmark Bookmark { + public SDBookmark Bookmark { get { return bookmark; } } - public BookmarkNode(Bookmark bookmark) + public BookmarkNode(SDBookmark bookmark) { drawDefault = false; this.bookmark = bookmark; diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs index ebc664c0e4..3ad6aca7ec 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/SharpDevelopTextAreaControl.cs @@ -45,6 +45,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor { errorDrawer = new ErrorDrawer(this); Document.FoldingManager.FoldingStrategy = new ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor.ParserFoldingStrategy(); + Document.BookmarkManager.Factory = new Bookmarks.SDBookmarkFactory(Document.BookmarkManager); Document.BookmarkManager.Added += new BookmarkEventHandler(BookmarkAdded); Document.BookmarkManager.Removed += new BookmarkEventHandler(BookmarkRemoved); GenerateEditActions(); @@ -55,16 +56,12 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor void BookmarkAdded(object sender, BookmarkEventArgs e) { - if (FileName != null) { - Bookmark.BookmarkManager.AddMark(FileName, e.Bookmark); - } + Bookmarks.BookmarkManager.AddMark((Bookmarks.SDBookmark)e.Bookmark); } void BookmarkRemoved(object sender, BookmarkEventArgs e) { - if (FileName != null) { - Bookmark.BookmarkManager.RemoveMark(FileName, e.Bookmark); - } + Bookmarks.BookmarkManager.RemoveMark((Bookmarks.SDBookmark)e.Bookmark); } public virtual ICompletionDataProvider CreateCodeCompletionDataProvider(bool ctrlSpace) @@ -88,15 +85,17 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor newControl.MouseWheel += new MouseEventHandler(TextAreaMouseWheel); newControl.DoHandleMousewheel = false; } + protected override void Dispose(bool disposing) { - base.Dispose(Disposing); + base.Dispose(disposing); if (disposing) { errorDrawer.Dispose(); CloseCodeCompletionWindow(this, EventArgs.Empty); CloseInsightWindow(this, EventArgs.Empty); } } + void CloseCodeCompletionWindow(object sender, EventArgs e) { if (codeCompletionWindow != null) { @@ -145,36 +144,6 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor } } -// void IconBarMouseDown(AbstractMargin iconBar, Point mousepos, MouseButtons mouseButtons) -// { -// int realline = iconBar.TextArea.TextView.GetLogicalLine(mousepos); -// if (realline >= 0 && realline < iconBar.TextArea.Document.TotalNumberOfLines) { - // -// if (DebuggerService.CurrentDebugger.SupportsExecutionControl) { -// DebuggerService.ToggleBreakpointAt(FileName, realline + 1, 0); -// iconBar.TextArea.Refresh(iconBar); -// } -// } -// } - // -// void PaintIconBarBreakPoints(AbstractMargin iconBar, Graphics g, Rectangle rect) -// { - // -// lock (DebuggerService.Breakpoints) { -// foreach (Breakpoint breakpoint in DebuggerService.Breakpoints) { -// try { -// if (Path.GetFullPath(breakpoint.FileName) == Path.GetFullPath(FileName)) { -// int lineNumber = iconBar.TextArea.Document.GetVisibleLine(breakpoint.LineNumber - 1); -// int yPos = (int)(lineNumber * iconBar.TextArea.TextView.FontHeight) - iconBar.TextArea.VirtualTop.Y; -// if (yPos >= rect.Y && yPos <= rect.Bottom) { -// ((IconBarMargin)iconBar).DrawBreakpoint(g, yPos, breakpoint.IsEnabled); -// } -// } -// } catch (Exception) {} -// } -// } -// } - void CaretPositionChanged(object sender, EventArgs e) { StatusBarService.SetCaretPosition(ActiveTextAreaControl.TextArea.TextView.GetVisualColumn(ActiveTextAreaControl.Caret.Line, ActiveTextAreaControl.Caret.Column), ActiveTextAreaControl.Caret.Line, ActiveTextAreaControl.Caret.Column); @@ -229,6 +198,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor protected override void OnFileNameChanged(EventArgs e) { base.OnFileNameChanged(e); + ((Bookmarks.SDBookmarkFactory)Document.BookmarkManager.Factory).ChangeFilename(this.FileName); ActivateQuickClassBrowserOnDemand(); } diff --git a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs index 9cd59f6928..f9622640ec 100644 --- a/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs +++ b/src/Main/Base/Project/Src/TextEditor/Gui/Editor/TextEditorDisplayBinding.cs @@ -322,10 +322,10 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor TitleName = Path.GetFileName(fileName); IsDirty = false; SetWatcher(); - foreach (Bookmark.Bookmark mark in Bookmark.BookmarkManager.GetBookmarks(fileName)) { - textAreaControl.Document.BookmarkManager.Marks.Add(mark.CreateBookmark(textAreaControl.Document)); + foreach (Bookmarks.SDBookmark mark in Bookmarks.BookmarkManager.GetBookmarks(fileName)) { + mark.Document = textAreaControl.Document; + textAreaControl.Document.BookmarkManager.Marks.Add(mark); } - } public Properties CreateMemento()