Skip to content

Commit 103511f

Browse files
committed
fixed ToDoItem selection
1 parent 547e450 commit 103511f

File tree

5 files changed

+38
-19
lines changed

5 files changed

+38
-19
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Linq;
2+
using Microsoft.Vbe.Interop;
3+
4+
namespace Rubberduck.Extensions
5+
{
6+
/// <summary>
7+
/// VBE CodeModule extension methods.
8+
/// </summary>
9+
public static class CodeModuleExtensions
10+
{
11+
/// <summary>
12+
/// Gets an array of strings where each element is a line of code in the module.
13+
/// </summary>
14+
public static string[] Code(this CodeModule module)
15+
{
16+
var lines = module.CountOfLines;
17+
if (lines == 0)
18+
{
19+
return new string[]{};
20+
}
21+
22+
return module.get_Lines(1, lines).Replace("\r", string.Empty).Split('\n');
23+
}
24+
}
25+
}

RetailCoder.VBE/Extensions/CodePaneExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
namespace Rubberduck.Extensions
77
{
8-
/// <summary> VBE Code Pane extensions. </summary>
8+
/// <summary>
9+
/// VBE Code Pane extension methods.
10+
/// </summary>
911
[ComVisible(false)]
1012
public static class CodePaneExtensions
1113
{

RetailCoder.VBE/ToDoItems/ToDoItem.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@ public struct ToDoItem
1313
private readonly string _description;
1414
public string Description { get { return _description; } }
1515

16-
private readonly string _projectName;
17-
public string ProjectName { get { return _projectName; } }
18-
19-
private readonly string _moduleName;
20-
public string ModuleName { get { return _moduleName; } }
21-
22-
private readonly int _lineNumber;
23-
public int LineNumber { get { return _lineNumber; } }
16+
private readonly QualifiedSelection _selection;
17+
public QualifiedSelection Selection { get { return _selection; } }
2418

2519
public ToDoItem(TaskPriority priority, CommentNode comment)
2620
: this(priority, comment.Comment, comment.QualifiedSelection)
@@ -31,9 +25,7 @@ public ToDoItem(TaskPriority priority, string description, QualifiedSelection qu
3125
{
3226
_priority = priority;
3327
_description = description;
34-
_projectName = qualifiedSelection.QualifiedName.ProjectName;
35-
_moduleName = qualifiedSelection.QualifiedName.ModuleName;
36-
_lineNumber = qualifiedSelection.Selection.StartLine;
28+
_selection = qualifiedSelection;
3729
}
3830
}
3931
}

RetailCoder.VBE/UI/ToDoItems/ToDoExplorerDockablePresenter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ private IEnumerable<ToDoItem> GetToDoMarkers(CommentNode comment)
5757
private void NavigateToDoItem(object sender, ToDoItemClickEventArgs e)
5858
{
5959
var project = VBE.VBProjects.Cast<VBProject>()
60-
.FirstOrDefault(p => p.Name == e.Selection.ProjectName);
60+
.FirstOrDefault(p => p.Name == e.SelectedItem.Selection.QualifiedName.ProjectName);
6161

6262
if (project == null)
6363
{
6464
return;
6565
}
6666

6767
var component = project.VBComponents.Cast<VBComponent>()
68-
.FirstOrDefault(c => c.Name == e.Selection.ModuleName);
68+
.FirstOrDefault(c => c.Name == e.SelectedItem.Selection.QualifiedName.ModuleName);
6969

7070
if (component == null)
7171
{
@@ -74,7 +74,7 @@ private void NavigateToDoItem(object sender, ToDoItemClickEventArgs e)
7474

7575
var codePane = component.CodeModule.CodePane;
7676

77-
codePane.SetSelection(e.Selection.LineNumber);
77+
codePane.SetSelection(e.SelectedItem.Selection.Selection);
7878
codePane.ForceFocus();
7979
}
8080
}

RetailCoder.VBE/UI/ToDoItems/ToDoItemClickEventArgs.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ namespace Rubberduck.UI.ToDoItems
77
[ComVisible(false)]
88
public class ToDoItemClickEventArgs : EventArgs
99
{
10-
public ToDoItemClickEventArgs(ToDoItem selection)
10+
public ToDoItemClickEventArgs(ToDoItem selectedItem)
1111
{
12-
_selection = selection;
12+
_selectedItem = selectedItem;
1313
}
1414

15-
private readonly ToDoItem _selection;
16-
public ToDoItem Selection { get { return _selection; } }
15+
private readonly ToDoItem _selectedItem;
16+
public ToDoItem SelectedItem { get { return _selectedItem; } }
1717
}
1818
}

0 commit comments

Comments
 (0)