|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
3 | 3 | using System.Linq; |
| 4 | +using System.Text; |
4 | 5 | using System.Windows.Media.Imaging; |
5 | 6 | using Rubberduck.Parsing.Grammar; |
6 | 7 | using Rubberduck.Parsing.Symbols; |
@@ -80,6 +81,25 @@ public CodeExplorerMemberViewModel(CodeExplorerItemViewModel parent, Declaration |
80 | 81 | _icon = Mappings[key]; |
81 | 82 | } |
82 | 83 |
|
| 84 | + private string RemoveExtraWhiteSpace(string value) |
| 85 | + { |
| 86 | + var newStr = new StringBuilder(); |
| 87 | + var trimmedJoinedString = value.Replace(" _\r\n", " ").Trim(); |
| 88 | + |
| 89 | + for (var i = 0; i < trimmedJoinedString.Length; i++) |
| 90 | + { |
| 91 | + // this will not throw because `Trim` ensures the first character is not whitespace |
| 92 | + if (char.IsWhiteSpace(trimmedJoinedString[i]) && char.IsWhiteSpace(trimmedJoinedString[i - 1])) |
| 93 | + { |
| 94 | + continue; |
| 95 | + } |
| 96 | + |
| 97 | + newStr.Append(trimmedJoinedString[i]); |
| 98 | + } |
| 99 | + |
| 100 | + return newStr.ToString(); |
| 101 | + } |
| 102 | + |
83 | 103 | private readonly string _name; |
84 | 104 | public override string Name { get { return _name; } } |
85 | 105 |
|
@@ -108,11 +128,11 @@ public override string NameWithSignature |
108 | 128 | || _declaration.DeclarationType == DeclarationType.PropertySet) |
109 | 129 | { |
110 | 130 | // 6 being the three-letter "get/let/set" + parens + space |
111 | | - _signature = Name.Insert(Name.Length - 6, context.GetText()); |
| 131 | + _signature = Name.Insert(Name.Length - 6, RemoveExtraWhiteSpace(context.GetText())); |
112 | 132 | } |
113 | 133 | else |
114 | 134 | { |
115 | | - _signature = Name + context.GetText(); |
| 135 | + _signature = Name + RemoveExtraWhiteSpace(context.GetText()); |
116 | 136 | } |
117 | 137 | return _signature; |
118 | 138 | } |
|
0 commit comments