4
4
using System . IO ;
5
5
using System . Linq ;
6
6
using System . Runtime . InteropServices ;
7
+ using System . Text ;
7
8
using Rubberduck . VBEditor . Events ;
8
9
using Rubberduck . VBEditor . Extensions ;
9
10
using Rubberduck . VBEditor . SafeComWrappers . Abstract ;
@@ -108,8 +109,6 @@ public void ImportSourceFile(string path)
108
109
return ;
109
110
}
110
111
111
- var codeString = File . ReadAllText ( path ) ;
112
- var codeLines = codeString . Split ( new [ ] { Environment . NewLine } , StringSplitOptions . None ) ;
113
112
if ( ext == ComponentTypeExtensions . DocClassExtension )
114
113
{
115
114
try
@@ -123,6 +122,8 @@ public void ImportSourceFile(string path)
123
122
124
123
var component = this [ name ] ;
125
124
component . CodeModule . Clear ( ) ;
125
+
126
+ var codeString = File . ReadAllText ( path ) ;
126
127
component . CodeModule . AddFromString ( codeString ) ;
127
128
}
128
129
else if ( ext == ComponentTypeExtensions . FormExtension )
@@ -138,6 +139,9 @@ public void ImportSourceFile(string path)
138
139
139
140
var component = this [ name ] ;
140
141
142
+ var codeString = File . ReadAllText ( path , Encoding . Default ) ; //The VBE uses the current ANSI codepage from the windows settings to export and import.
143
+ var codeLines = codeString . Split ( new [ ] { Environment . NewLine } , StringSplitOptions . None ) ;
144
+
141
145
var nonAttributeLines = codeLines . TakeWhile ( line => ! line . StartsWith ( "Attribute" ) ) . Count ( ) ;
142
146
var attributeLines = codeLines . Skip ( nonAttributeLines ) . TakeWhile ( line => line . StartsWith ( "Attribute" ) ) . Count ( ) ;
143
147
var declarationsStartLine = nonAttributeLines + attributeLines + 1 ;
0 commit comments