1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
+ using System . Net . Configuration ;
4
5
using Rubberduck . VBEditor ;
5
6
using Rubberduck . VBEditor . SafeComWrappers . Abstract ;
6
7
using Rubberduck . VBEditor . SafeComWrappers . VBA ;
@@ -71,13 +72,8 @@ public void Indent(IVBComponent component)
71
72
var codeLines = module . GetLines ( 1 , lineCount ) . Replace ( "\r " , string . Empty ) . Split ( '\n ' ) ;
72
73
var indented = Indent ( codeLines , component . Name ) . ToArray ( ) ;
73
74
74
- for ( var i = 0 ; i < lineCount ; i ++ )
75
- {
76
- if ( module . GetLines ( i + 1 , 1 ) != indented [ i ] )
77
- {
78
- component . CodeModule . ReplaceLine ( i + 1 , indented [ i ] ) ;
79
- }
80
- }
75
+ module . DeleteLines ( 1 , lineCount ) ;
76
+ module . InsertLines ( 1 , string . Join ( "\r \n " , indented ) ) ;
81
77
}
82
78
83
79
public void Indent ( IVBComponent component , string procedureName , Selection selection )
@@ -93,13 +89,8 @@ public void Indent(IVBComponent component, string procedureName, Selection selec
93
89
94
90
var indented = Indent ( codeLines , procedureName ) . ToArray ( ) ;
95
91
96
- for ( var i = 0 ; i < selection . EndLine - selection . StartLine ; i ++ )
97
- {
98
- if ( module . GetLines ( selection . StartLine + i , 1 ) != indented [ i ] )
99
- {
100
- component . CodeModule . ReplaceLine ( selection . StartLine + i , indented [ i ] ) ;
101
- }
102
- }
92
+ module . DeleteLines ( selection . StartLine , selection . LineCount ) ;
93
+ module . InsertLines ( selection . StartLine , string . Join ( "\r \n " , indented ) ) ;
103
94
}
104
95
105
96
private IEnumerable < LogicalCodeLine > BuildLogicalCodeLines ( IEnumerable < string > lines )
0 commit comments