@@ -78,7 +78,7 @@ export async function resolveContextExpression(): Promise<void> {
7878
7979type ContextExpressionInfo = {
8080 text : string ;
81- replacementEnd ?: vscode . Position ;
81+ replacementRange ?: vscode . Range ;
8282} ;
8383
8484function getContextExpressionInfo ( document : vscode . TextDocument , selection : vscode . Selection ) : ContextExpressionInfo {
@@ -88,19 +88,16 @@ function getContextExpressionInfo(document: vscode.TextDocument, selection: vsco
8888 } ;
8989 }
9090
91- const startLine = selection . start . line ;
92- const start = document . lineAt ( startLine ) . range . start ;
91+ let replacementRange = new vscode . Range ( selection . start , selection . end ) ;
9392
94- let lastLine = selection . end . line ;
9593 if ( selection . end . character === 0 && selection . end . line > selection . start . line ) {
96- lastLine = selection . end . line - 1 ;
94+ const adjustedEnd = document . lineAt ( selection . end . line - 1 ) . range . end ;
95+ replacementRange = new vscode . Range ( selection . start , adjustedEnd ) ;
9796 }
9897
99- const end = document . lineAt ( lastLine ) . range . end ;
100-
10198 return {
102- text : document . getText ( new vscode . Range ( start , end ) ) ,
103- replacementEnd : end ,
99+ text : document . getText ( replacementRange ) ,
100+ replacementRange ,
104101 } ;
105102}
106103
@@ -164,9 +161,7 @@ async function applyResolvedTextExpression(
164161 const fallbackLine = document . lineAt ( selection . active . line ) ;
165162 rangeToReplace = fallbackLine . range ;
166163 } else {
167- const start = document . lineAt ( selection . start . line ) . range . start ;
168- const replacementEnd = contextInfo . replacementEnd ?? document . lineAt ( selection . end . line ) . range . end ;
169- rangeToReplace = new vscode . Range ( start , replacementEnd ) ;
164+ rangeToReplace = contextInfo . replacementRange ?? new vscode . Range ( selection . start , selection . end ) ;
170165 }
171166
172167 await editor . edit ( ( editBuilder ) => {
0 commit comments