@@ -150,19 +150,26 @@ module.exports = {
150150 * Get the characters used for indentation on the line to be matched
151151 * @param {Object } tokens Locations of the opening bracket, closing bracket and last prop
152152 * @param {String } expectedLocation Expected location for the closing bracket
153+ * @param {Number } correctColumn Expected column for the closing bracket
153154 * @return {String } The characters used for indentation
154155 */
155- function getIndentation ( tokens , expectedLocation ) {
156+ function getIndentation ( tokens , expectedLocation , correctColumn ) {
157+ var indentation , spaces = [ ] ;
156158 switch ( expectedLocation ) {
157159 case 'props-aligned' :
158- return / ^ \s * / . exec ( sourceCode . lines [ tokens . lastProp . lastLine ] ) [ 0 ] ;
160+ indentation = / ^ \s * / . exec ( sourceCode . lines [ tokens . lastProp . firstLine - 1 ] ) [ 0 ] ;
161+ break ;
159162 case 'tag-aligned' :
160- return / ^ \s * / . exec ( sourceCode . lines [ tokens . opening . line ] ) [ 0 ] ;
161163 case 'line-aligned' :
162- return / ^ \s * / . exec ( sourceCode . lines [ tokens . openingStartOfLine . line ] ) [ 0 ] ;
164+ indentation = / ^ \s * / . exec ( sourceCode . lines [ tokens . opening . line - 1 ] ) [ 0 ] ;
163165 default :
164- return '' ;
166+ indentation = '' ;
165167 }
168+ if ( indentation . length + 1 < correctColumn ) {
169+ // Non-whitespace characters were included in the column offset
170+ spaces = new Array ( + correctColumn + 1 - indentation . length ) ;
171+ }
172+ return indentation + spaces . join ( ' ' ) ;
166173 }
167174
168175 /**
@@ -264,7 +271,7 @@ module.exports = {
264271 case 'tag-aligned' :
265272 case 'line-aligned' :
266273 return fixer . replaceTextRange ( [ cachedLastAttributeEndPos , node . end ] ,
267- '\n' + getIndentation ( tokens , expectedLocation ) + closingTag ) ;
274+ '\n' + getIndentation ( tokens , expectedLocation , correctColumn ) + closingTag ) ;
268275 default :
269276 return true ;
270277 }
0 commit comments