File tree 2 files changed +11
-9
lines changed
2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -115,10 +115,11 @@ exports.provider = {
115
115
if ( options . suggestion . atomTS_IsImport ) {
116
116
options . editor . moveToBeginningOfLine ( ) ;
117
117
options . editor . selectToEndOfLine ( ) ;
118
- var groups = / ^ \s * i m p o r t \s * ( \w * ) \s * = \s * r e q u i r e \s * \( \s * ( [ " ' ] ) / . exec ( options . editor . getSelectedText ( ) ) ;
119
- var alias = groups [ 1 ] ;
120
- quote = quote || groups [ 2 ] ;
121
- options . editor . replaceSelectedText ( null , function ( ) { return "import " + alias + " = require(" + quote + options . suggestion . atomTS_IsImport . relativePath + quote + ");" ; } ) ;
118
+ var groups = / ^ ( \s * ) i m p o r t \s * ( \w * ) \s * = \s * r e q u i r e \s * \( \s * ( [ " ' ] ) / . exec ( options . editor . getSelectedText ( ) ) ;
119
+ var leadingWhiteSpace = groups [ 1 ] ;
120
+ var alias = groups [ 2 ] ;
121
+ quote = quote || groups [ 3 ] ;
122
+ options . editor . replaceSelectedText ( null , function ( ) { return leadingWhiteSpace + "import " + alias + " = require(" + quote + options . suggestion . atomTS_IsImport . relativePath + quote + ");" ; } ) ;
122
123
}
123
124
if ( options . suggestion . atomTS_IsES6Import ) {
124
125
var row = options . editor . getCursorBufferPosition ( ) . row ;
Original file line number Diff line number Diff line change @@ -214,13 +214,14 @@ export var provider: autocompleteplus.Provider = {
214
214
if ( options . suggestion . atomTS_IsImport ) {
215
215
options . editor . moveToBeginningOfLine ( ) ;
216
216
options . editor . selectToEndOfLine ( ) ;
217
- var groups = / ^ \s * i m p o r t \s * ( \w * ) \s * = \s * r e q u i r e \s * \( \s * ( [ " ' ] ) / . exec ( options . editor . getSelectedText ( ) ) ;
218
- var alias = groups [ 1 ] ;
217
+ var groups = / ^ ( \s * ) i m p o r t \s * ( \w * ) \s * = \s * r e q u i r e \s * \( \s * ( [ " ' ] ) / . exec ( options . editor . getSelectedText ( ) ) ;
218
+ var leadingWhiteSpace = groups [ 1 ] ;
219
+ var alias = groups [ 2 ] ;
219
220
220
221
// Use the option if they have a preferred. Otherwise preserve
221
- quote = quote || groups [ 2 ] ;
222
-
223
- options . editor . replaceSelectedText ( null , function ( ) { return `import ${ alias } = require(${ quote } ${ options . suggestion . atomTS_IsImport . relativePath } ${ quote } );` ; } ) ;
222
+ quote = quote || groups [ 3 ] ;
223
+
224
+ options . editor . replaceSelectedText ( null , function ( ) { return `${ leadingWhiteSpace } import ${ alias } = require(${ quote } ${ options . suggestion . atomTS_IsImport . relativePath } ${ quote } );` ; } ) ;
224
225
}
225
226
if ( options . suggestion . atomTS_IsES6Import ) {
226
227
var { row} = options . editor . getCursorBufferPosition ( ) ;
You can’t perform that action at this time.
0 commit comments