Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Karlaš <david.karlas@microsoft.com>2019-05-29 14:16:54 +0300
committerDavid Karlaš <david.karlas@microsoft.com>2019-05-31 11:45:23 +0300
commitd3775e9259b72ce8f14ded23dbc9d62a09dcdda8 (patch)
tree278fbfe3d2235ab582ff5fd14b9825a583b254c5 /main/src/addins
parent37e4b4c384eddbf5f4e34f69148353b92ae1f1e0 (diff)
Fix 895583: Breakpoints not visible after renaming file
This is two part fix, part is in DebuggingService which is updating actual breakpoint to new file And other part is in new editor breakpoint integration which now doesn't use `readonly string file` but instead `textDocument.FilePath` which is mutable and updates when file is renamed and also listens for additional event.
Diffstat (limited to 'main/src/addins')
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/BreakpointManager.cs19
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Tags/AbstractCurrentStatementTagger.cs9
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs9
3 files changed, 28 insertions, 9 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/BreakpointManager.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/BreakpointManager.cs
index 44991e0ccb..f3f690e450 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/BreakpointManager.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/BreakpointManager.cs
@@ -10,22 +10,30 @@ namespace MonoDevelop.Debugger
class BreakpointManager
{
private ITextBuffer textBuffer;
- private readonly string file;
+ private readonly ITextDocument textDocument;
public BreakpointManager (ITextBuffer textBuffer)
{
this.textBuffer = textBuffer;
- file = textBuffer.GetFilePathOrNull ();
- if (file == null) {
+ if (textBuffer.Properties.TryGetProperty (typeof (ITextDocument), out textDocument) && textDocument.FilePath != null) {
+ textDocument.FileActionOccurred += TextDocument_FileActionOccurred;
+ } else {
LoggingService.LogWarning ("Failed to get filename of textbuffer, breakpoints integration will not work.");
return;
}
textBuffer.Changed += TextBuffer_Changed;
DebuggingService.Breakpoints.Changed += OnBreakpointsChanged;
DebuggingService.Breakpoints.BreakpointStatusChanged += OnBreakpointsChanged;
+ DebuggingService.Breakpoints.BreakpointModified += OnBreakpointsChanged;
OnBreakpointsChanged (null, null);
}
+ private void TextDocument_FileActionOccurred (object sender, TextDocumentFileActionEventArgs e)
+ {
+ if (e.FileActionType == FileActionTypes.DocumentRenamed)
+ OnBreakpointsChanged (null, null);
+ }
+
void TextBuffer_Changed (object sender, TextContentChangedEventArgs e)
{
foreach (var breakpoint in breakpoints.Values) {
@@ -55,7 +63,7 @@ namespace MonoDevelop.Debugger
var snapshot = textBuffer.CurrentSnapshot;
var newBreakpoints = new Dictionary<Breakpoint, ManagerBreakpoint> ();
bool needsUpdate = false;
- foreach (var breakpoint in DebuggingService.Breakpoints.GetBreakpointsAtFile (file)) {
+ foreach (var breakpoint in DebuggingService.Breakpoints.GetBreakpointsAtFile (textDocument.FilePath)) {
if (breakpoint.Line > snapshot.LineCount)
continue;
if (eventArgs is BreakpointEventArgs breakpointEventArgs && breakpointEventArgs.Breakpoint == breakpoint)
@@ -93,6 +101,9 @@ namespace MonoDevelop.Debugger
textBuffer.Changed -= TextBuffer_Changed;
DebuggingService.Breakpoints.Changed -= OnBreakpointsChanged;
DebuggingService.Breakpoints.BreakpointStatusChanged -= OnBreakpointsChanged;
+ DebuggingService.Breakpoints.BreakpointModified -= OnBreakpointsChanged;
+ if (textDocument != null)
+ textDocument.FileActionOccurred -= TextDocument_FileActionOccurred;
}
public IEnumerable<BreakpointSpan> GetBreakpoints (ITextSnapshot snapshot)
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Tags/AbstractCurrentStatementTagger.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Tags/AbstractCurrentStatementTagger.cs
index db3cc43c7c..800c7590fc 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Tags/AbstractCurrentStatementTagger.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.VSTextView/Tags/AbstractCurrentStatementTagger.cs
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Tagging;
using MonoDevelop.Debugger;
-using MonoDevelop.Ide.Editor;
using MonoDevelop.Ide;
using Mono.Debugging.Client;
using MonoDevelop.Core;
@@ -15,7 +14,7 @@ namespace MonoDevelop.Debugger
{
private readonly ITextBuffer textBuffer;
private readonly T tag;
- private readonly string filePath;
+ private readonly ITextDocument textDocument;
private readonly bool isGreen;
private ITextSnapshot snapshotAtStartOfDebugging;
@@ -23,7 +22,7 @@ namespace MonoDevelop.Debugger
{
this.textBuffer = textBuffer;
this.snapshotAtStartOfDebugging = textBuffer.CurrentSnapshot;
- this.filePath = textBuffer.GetFilePathOrNull ();
+ textBuffer.Properties.TryGetProperty (typeof (ITextDocument), out textDocument);
this.tag = tag;
this.isGreen = isGreen;
DebuggingService.CurrentFrameChanged += OnDebuggerCurrentStatementChanged;
@@ -68,8 +67,8 @@ namespace MonoDevelop.Debugger
SourceLocation CheckLocationIsInFile (SourceLocation location)
{
- if (!string.IsNullOrEmpty (filePath) && location != null && !string.IsNullOrEmpty (location.FileName)
- && ((FilePath)location.FileName).FullPath == ((FilePath)filePath).FullPath)
+ if (!string.IsNullOrEmpty (textDocument?.FilePath) && location != null && !string.IsNullOrEmpty (location.FileName)
+ && ((FilePath)location.FileName).FullPath == ((FilePath)textDocument.FilePath).FullPath)
return location;
return null;
}
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs
index af467d42fd..0bb071737d 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DebuggingService.cs
@@ -112,6 +112,15 @@ namespace MonoDevelop.Debugger
evaluators = null;
});
IdeApp.Exiting += IdeApp_Exiting;
+ FileService.FileRenamed += FileService_FileRenamed;
+ FileService.FileMoved += FileService_FileRenamed;
+ }
+
+ private static void FileService_FileRenamed (object sender, FileCopyEventArgs e)
+ {
+ foreach (var file in e) {
+ breakpoints.FileRenamed (file.SourceFile, file.TargetFile);
+ }
}
static void IdeApp_Exiting (object sender, ExitEventArgs args)