Skip to content

Commit c5f79f4

Browse files
Copilotntotten
andauthored
Log EditorConfig usage and resolved configuration to prevent silent config conflicts (#3867)
* Initial plan * Add logging for EditorConfig usage and resolved configuration - Log when EditorConfig support is enabled - Log the config file path if found - Log when settings come from .editorconfig (when no Prettier config exists) - Log the complete resolved configuration - Simplify logging messages in PrettierEditService This helps users understand what configuration is being applied, especially when .editorconfig has settings that affect formatting. Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com> * Add logging for custom config path from VS Code settings Also log when a custom prettier.configPath is specified in VS Code settings to provide complete visibility into what configuration is being used. Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: ntotten <282782+ntotten@users.noreply.github.com>
1 parent 53a3b1c commit c5f79f4

2 files changed

Lines changed: 44 additions & 5 deletions

File tree

src/ModuleResolverNode.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,33 @@ export class ModuleResolver implements ModuleResolverInterface {
402402
return "error";
403403
}
404404

405+
// Log what config file was found (if any)
406+
if (configPath) {
407+
this.loggingService.logInfo(`Using config file at ${configPath}`);
408+
}
409+
410+
// Log if editorconfig will be considered
411+
if (vscodeConfig.useEditorConfig) {
412+
this.loggingService.logInfo(
413+
"EditorConfig support is enabled, checking for .editorconfig files",
414+
);
415+
}
416+
405417
let resolvedConfig: PrettierOptions | null;
406418
try {
419+
const customConfigPath = vscodeConfig.configPath
420+
? getWorkspaceRelativePath(fileName, vscodeConfig.configPath)
421+
: undefined;
422+
423+
// Log if a custom config path is specified in VS Code settings
424+
if (customConfigPath) {
425+
this.loggingService.logInfo(
426+
`Using custom config path from settings: ${customConfigPath}`,
427+
);
428+
}
429+
407430
const resolveConfigOptions: PrettierResolveConfigOptions = {
408-
config: vscodeConfig.configPath
409-
? getWorkspaceRelativePath(fileName, vscodeConfig.configPath)
410-
: configPath,
431+
config: customConfigPath ?? configPath,
411432
editorconfig: vscodeConfig.useEditorConfig,
412433
};
413434
resolvedConfig = await prettierInstance.resolveConfig(
@@ -419,6 +440,24 @@ export class ModuleResolver implements ModuleResolverInterface {
419440
return "error";
420441
}
421442

443+
// Log what configuration was resolved
444+
if (resolvedConfig) {
445+
this.loggingService.logInfo("Resolved config:", resolvedConfig);
446+
}
447+
448+
// Determine config source for better user feedback
449+
if (!configPath && resolvedConfig && vscodeConfig.useEditorConfig) {
450+
// Config was resolved but no Prettier config file was found
451+
// This means settings came from .editorconfig
452+
this.loggingService.logInfo(
453+
"No Prettier config file found, but settings were loaded from .editorconfig",
454+
);
455+
} else if (!configPath && !resolvedConfig) {
456+
this.loggingService.logInfo(
457+
"No local configuration (i.e. .prettierrc or .editorconfig) detected, will fall back to VS Code configuration",
458+
);
459+
}
460+
422461
if (!vscodeConfig.requireConfig) {
423462
return resolvedConfig;
424463
}

src/PrettierEditService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,8 @@ export default class PrettierEditService implements Disposable {
677677

678678
this.loggingService.logInfo(
679679
fallbackToVSCodeConfig
680-
? "No local configuration (i.e. .prettierrc or .editorconfig) detected, falling back to VS Code configuration"
681-
: "Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used",
680+
? "Using VS Code configuration"
681+
: "Using local configuration (VS Code configuration will not be used)",
682682
);
683683

684684
let rangeFormattingOptions: RangeFormattingOptions | undefined;

0 commit comments

Comments
 (0)