@@ -547,4 +547,44 @@ function createDocumentSymbol(
547547 assert . deepStrictEqual ( result ! . range , new Range ( 1 , 0 , 1 , 0 ) ) ;
548548 assert . strictEqual ( result ! . newText , '' ) ;
549549 } ) ;
550+
551+ test ( 'insertion on next line in fieldLabels object' , ( ) => {
552+ const doc = `import React, { useState } from "react";
553+
554+ interface FormData {
555+ firstName: string;
556+ lastName: string;
557+ password: string;
558+ email: string;
559+ age: string;
560+ city: string;
561+ }
562+
563+ const initialFormData: FormData = {
564+ firstName: "",
565+ lastName: "",
566+ password: "",
567+ email: "",
568+ age: "",
569+ city: "",
570+ };
571+
572+ const fieldLabels: Record<keyof FormData, string> = {
573+ firstName: "First Name",
574+ lastName: "Last Name",
575+ email: "Email Address",
576+ age: "Age",
577+ city: "City",
578+ };
579+ ` ;
580+ const document = createTextDocumentData ( Uri . from ( { scheme : 'test' , path : '/test/file.tsx' } ) , doc , 'typescriptreact' ) . document ;
581+ const cursorPosition = new Position ( 22 , 26 ) ; // end of ` lastName: "Last Name",`
582+ const replaceRange = new Range ( 23 , 0 , 23 , 0 ) ;
583+ const replaceText = ' password: "Password",\n' ;
584+
585+ const result = toInlineSuggestion ( cursorPosition , document , replaceRange , replaceText , true ) ;
586+ assert . isDefined ( result ) ;
587+ assert . deepStrictEqual ( result ! . range , new Range ( 22 , 26 , 22 , 26 ) ) ;
588+ assert . strictEqual ( result ! . newText , '\n' + replaceText ) ;
589+ } ) ;
550590} ) ;
0 commit comments