Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions tests/cases/fourslash/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
26 changes: 26 additions & 0 deletions tests/cases/fourslash/getEditsForFileRename_preferences.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/// <reference path='fourslash.ts' />

// @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",
},
});