diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index dcfefdbab26..4d9e653f27d 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3365,9 +3365,9 @@ Actual: ${stringify(fullActual)}`); this.cancellationToken.resetCancelled(); } - public getEditsForFileRename({ oldPath, newPath, newFileContents }: FourSlashInterface.GetEditsForFileRenameOptions): void { + public getEditsForFileRename({ oldPath, newPath, newFileContents, preferences }: FourSlashInterface.GetEditsForFileRenameOptions): void { const test = (fileContents: { readonly [fileName: string]: string }, description: string): void => { - const changes = this.languageService.getEditsForFileRename(oldPath, newPath, this.formatCodeSettings, ts.emptyOptions); + const changes = this.languageService.getEditsForFileRename(oldPath, newPath, this.formatCodeSettings, preferences); this.testNewFileContents(changes, fileContents, description); }; @@ -4890,6 +4890,7 @@ namespace FourSlashInterface { readonly oldPath: string; readonly newPath: string; readonly newFileContents: { readonly [fileName: string]: string }; + readonly preferences?: ts.UserPreferences; } export interface MoveToNewFileOptions { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 5585b49ee71..897d6693f60 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -336,9 +336,10 @@ declare namespace FourSlashInterface { ProjectInfo(expected: string[]): void; allRangesAppearInImplementationList(markerName: string): void; getEditsForFileRename(options: { - oldPath: string; - newPath: string; - newFileContents: { [fileName: string]: string }; + readonly oldPath: string; + readonly newPath: string; + readonly newFileContents: { readonly [fileName: string]: string }; + readonly preferences?: UserPreferences; }): void; moveToNewFile(options: { readonly newFileContents: { readonly [fileName: string]: string }; diff --git a/tests/cases/fourslash/getEditsForFileRename_preferences.ts b/tests/cases/fourslash/getEditsForFileRename_preferences.ts new file mode 100644 index 00000000000..440abbb0a9f --- /dev/null +++ b/tests/cases/fourslash/getEditsForFileRename_preferences.ts @@ -0,0 +1,26 @@ +/// + +// @Filename: /dir/a.ts +////export const a = 0; + +// @Filename: /dir/b.ts +////import {} from "dir/a"; +////import {} from 'dir/a'; + +// @Filename: /tsconfig.json +////{ "compilerOptions": { "baseUrl": "." } } + +verify.getEditsForFileRename({ + oldPath: "/dir/a.ts", + newPath: "/dir/a1.ts", + newFileContents: { + "/dir/b.ts": +`import {} from "dir/a1"; +import {} from 'dir/a1';`, + }, + preferences: { + importModuleSpecifierPreference: "non-relative", + // No effect because we are changing existing imports, which already have quotes + quotePreference: "single", + }, +});