@@ -86,6 +86,10 @@ async function applyStructuralCommentsToSingleSelectionLines(
8686) {
8787 const originalSelections = [ ...editor . selections ] ;
8888 const singleSelection = editor . selections [ 0 ] ;
89+ const partialSelectionStartColumn =
90+ ! singleSelection . isEmpty && affectedLineNumbers . length > 1
91+ ? singleSelection . start . character
92+ : undefined ;
8993 const descendingLineNumbers = [ ...new Set ( affectedLineNumbers ) ] . sort ( ( a , b ) => b - a ) ;
9094 const affectedLineSet = new Set ( affectedLineNumbers ) ;
9195 const originalFirstNonWSMap = new Map < number , number > ( ) ;
@@ -137,7 +141,11 @@ async function applyStructuralCommentsToSingleSelectionLines(
137141 affectedLineNumbers . length > 1
138142 ? resolvedAlignedCommentColumn
139143 : originalInsertionColumnMap . get ( lineNum ) ?? firstNonWhitespace ;
140- const insertionColumn = Math . min ( rawInsertionColumn , currentLine . text . length ) ;
144+ const firstLineInsertionColumn =
145+ partialSelectionStartColumn !== undefined && lineNum === singleSelection . start . line
146+ ? Math . max ( rawInsertionColumn , partialSelectionStartColumn )
147+ : rawInsertionColumn ;
148+ const insertionColumn = Math . min ( firstLineInsertionColumn , currentLine . text . length ) ;
141149 originalInsertionColumnMap . set ( lineNum , insertionColumn ) ;
142150 const insertionOffset = editor . document . offsetAt (
143151 new vscode . Position ( lineNum , insertionColumn )
0 commit comments