diff --git a/src/completion/completer/macro.ts b/src/completion/completer/macro.ts index 803866769..590a45561 100644 --- a/src/completion/completer/macro.ts +++ b/src/completion/completer/macro.ts @@ -410,8 +410,11 @@ function entryCmdToCompletion(item: MacroRaw, packageName?: string, postAction?: if (! (item.arg.snippet.match(/\$\{?2/) || (item.arg.snippet.match(/\$\{?0/) && item.arg.snippet.match(/\$\{?1/)))) { item.arg.snippet = item.arg.snippet.replace(/\$1|\$\{1\}/, '$${1:$${TM_SELECTED_TEXT}}').replace(/\$\{1:([^$}]+)\}/, '$${1:$${TM_SELECTED_TEXT:$1}}') } - // Remove the %keyvals component - item.arg.snippet = item.arg.snippet.replace(/%keyvals/g, '') + item.arg.snippet = item.arg.snippet + // Remove the %:translatable component + .replace(/%:translatable/g, '') + // Remove the %randomword component + .replace(/%\w+/g, '') suggestion.insertText = new vscode.SnippetString(item.arg.snippet) } else { suggestion.insertText = item.name diff --git a/test/units/15_completion_macro.test.ts b/test/units/15_completion_macro.test.ts index 71cfb13b8..f0190db6e 100644 --- a/test/units/15_completion_macro.test.ts +++ b/test/units/15_completion_macro.test.ts @@ -120,6 +120,26 @@ describe(path.basename(__filename).split('.')[0] + ':', () => { assert.ok(!snippet.value.includes('%keyvals'), snippet.value) }) + it('should remove `%:translatable` from macro argument hints', async () => { + readStub.resolves('\\usepackage{amsmath}') + await lw.cache.refreshCache(texPath) + + const suggestion = getSuggestions().find(s => s.label === '\\dfrac{}{}') + const snippet = suggestion?.insertText + assert.ok(snippet instanceof vscode.SnippetString) + assert.ok(!snippet.value.includes('%:translatable'), snippet.value) + }) + + it('should remove other `%` components from macro argument hints', async () => { + readStub.resolves('\\usepackage{acro}') + await lw.cache.refreshCache(texPath) + + const suggestion = getSuggestions().find(s => s.label === '\\acrotranslate{}') + const snippet = suggestion?.insertText + assert.ok(snippet instanceof vscode.SnippetString) + assert.ok(!snippet.value.includes('%'), snippet.value) + }) + it('should not provide argument hints if `intellisense.argumentHint.enabled` is false', async () => { readStub.resolves('\\usepackage{import}') await lw.cache.refreshCache(texPath)