Skip to content

Commit

Permalink
fix(typescript): allowTextChangesInNewFiles never true for embedded…
Browse files Browse the repository at this point in the history
… documents
  • Loading branch information
johnsoncodehk committed May 10, 2024
1 parent 5987cf8 commit 811707e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/typescript/lib/configs/getUserPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export async function getUserPreferences(
if (ctx.language.typescript) {
currentDirectory = ctx.language.typescript.languageServiceHost.getCurrentDirectory();
}
const documentUri = ctx.decodeEmbeddedDocumentUri(document.uri)?.[0] ?? document.uri;
const config = await ctx.env.getConfiguration?.<any>(getConfigTitle(document)) ?? {};
const preferencesConfig = config?.preferences ?? {};
const preferences: ts.UserPreferences = {
Expand All @@ -20,7 +21,7 @@ export async function getUserPreferences(
importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferencesConfig),
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferencesConfig),
jsxAttributeCompletionStyle: getJsxAttributeCompletionStyle(preferencesConfig),
allowTextChangesInNewFiles: document.uri.startsWith('file://'),
allowTextChangesInNewFiles: documentUri.startsWith('file://'),
providePrefixAndSuffixTextForRename: (preferencesConfig.renameShorthandProperties ?? true) === false ? false : (preferencesConfig.useAliasesForRenames ?? true),
allowRenameOfImportPath: true,
includeAutomaticOptionalChainCompletions: config.suggest?.includeAutomaticOptionalChainCompletions ?? true,
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/lib/semanticFeatures/codeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export function register(ctx: SharedContext) {
if (resolveCommandSupport && resolveEditSupport) {
codeAction.data = data;
}
else if (!codeAction.disabled && document) {
else if (!codeAction.disabled) {
resolveRefactorCodeAction(ctx, codeAction, data, document, formatOptions, preferences);
}
codeActions.push(codeAction);
Expand Down

0 comments on commit 811707e

Please sign in to comment.