Skip to content

Commit be9c5d0

Browse files
Copilotamunger
andcommitted
Fix #Command issue in instruction comments by using reliable format function
The issue was in DataScience.instructionComments where l10n.t was expected to handle {0} placeholder replacement. If l10n.t failed to replace {0} correctly, it could result in corrupted output like 'Command' instead of '# %%'. The fix ensures placeholder replacement is always handled by the reliable format() function regardless of l10n.t behavior, while preserving localization. Co-authored-by: amunger <[email protected]>
1 parent f2690ff commit be9c5d0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/platform/common/utils/localize.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { l10n } from 'vscode';
55
import { PythonEnvironment } from '../../pythonEnvironments/info';
66
import { fromNow } from './date';
77
import { getPythonEnvDisplayName } from '../../interpreter/helpers';
8+
import { format } from '../helpers';
89

910
function getInterpreterDisplayName(interpreter: PythonEnvironment) {
1011
return getPythonEnvDisplayName(interpreter);
@@ -525,8 +526,10 @@ export namespace DataScience {
525526
export const cellStopOnErrorMessage = l10n.t('Cell was canceled due to an error in a previous cell.');
526527
export const scrollToCellTitleFormatMessage = (executionCount: number) =>
527528
l10n.t('Go to [{0}]', executionCount.toString());
528-
export const instructionComments = (cellMarker: string) =>
529-
l10n.t(`# To add a new cell, type '{0}'\n# To add a new markdown cell, type '{0} [markdown]'\n`, cellMarker);
529+
export const instructionComments = (cellMarker: string) => {
530+
const template = l10n.t(`# To add a new cell, type '{0}'\n# To add a new markdown cell, type '{0} [markdown]'\n`);
531+
return format(template, cellMarker);
532+
};
530533
export const exportButtonTitle = l10n.t('Export');
531534
export const exportAsQuickPickPlaceholder = l10n.t('Export As...');
532535
export const openExportedFileMessage = l10n.t('Would you like to open the exported file?');

0 commit comments

Comments
 (0)