File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -115,10 +115,11 @@ exports.provider = {
115115 if ( options . suggestion . atomTS_IsImport ) {
116116 options . editor . moveToBeginningOfLine ( ) ;
117117 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 + ");" ; } ) ;
122123 }
123124 if ( options . suggestion . atomTS_IsES6Import ) {
124125 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 = {
214214 if ( options . suggestion . atomTS_IsImport ) {
215215 options . editor . moveToBeginningOfLine ( ) ;
216216 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 ] ;
219220
220221 // 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 } );` ; } ) ;
224225 }
225226 if ( options . suggestion . atomTS_IsES6Import ) {
226227 var { row} = options . editor . getCursorBufferPosition ( ) ;
You can’t perform that action at this time.
0 commit comments