Change:
const prefixPos = position.column - (1 + start); const prefixRestLen = snippet.prefixLow.length - prefixPos; const endsWithPrefixRest = compareSubstring(lineContent, snippet.prefixLow, columnOffset, (columnOffset) + prefixRestLen, prefixPos, prefixPos + prefixRestLen); <del> const endColumn = endsWithPrefixRest === 0 ? position.column + prefixRestLen : position.column; const replace = Range.fromPositions(position.delta(0, -prefixPos), { lineNumber: position.lineNumber, column: endColumn }); </del> <ins> const startPosition = position.delta(0, -prefixPos); let endColumn = endsWithPrefixRest === 0 ? position.column + prefixRestLen : position.column; // First check if there is anything to the right of the cursor if (columnOffset < lineContent.length) { const autoClosingPairs = LanguageConfigurationRegistry.getAutoClosingPairs(languageId); const standardAutoClosingPairConditionals = autoClosingPairs.autoClosingPairsCloseSingleChar.get(lineContent[columnOffset]); // If the character to the right of the cursor is a closing character of an autoclosing pair if (standardAutoClosingPairConditionals?.some(p => // and the start position is the opening character of an autoclosing pair p.open === lineContent[startPosition.column - 1] && // and the snippet prefix contains the opening and closing pair at its edges snippet.prefix.startsWith(p.open) && snippet.prefix[snippet.prefix.length - 1] === p.close)) { // Eat the character that was likely inserted because of auto-closing pairs endColumn++; } } const replace = Range.fromPositions(startPosition, { lineNumber: position.lineNumber, column: endColumn }); </ins> const insert = replace.setEndPosition(position.lineNumber, position.column); suggestions.push(new SnippetCompletion(snippet, { replace, insert }));

Discussion:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Please search existing issues to avoid creating duplicates. --<!-- Also please test using the latest insiders build to make sure your issue has not already been fixed: --<!-- Use Help Report Issue to prefill these. --Version: 1.49.0-insider Commit: Date: 2020-08-17T17:11:16.078Z (1 day ago) Electron: 9.2.0 Chrome: 83.0.4103.122 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 19.6.0 Steps to Reproduce: Add the following python snippet: or PowerShell snippet: : which will cause auto-closing pair... (at this point you have where is the cursor) add a or and hit TAB or ENTER on the intellisense item NOTE THE TRAILING . Snippets and auto-closing pairs should play nice together so that the whole experience generates valid code. <!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes
Here's a javascript example for array destructuring: which gets you: when you type:
better example! A javascript example for : which gets you: when you type:
for verification, this: should get you: on insert mode replace (default is SHIFT + ENTER)
I'll note that it works fine in non-json files, but is reversed in a json file (as are the insert/replace hints in the suggestion box). W10
that seems like a separate issue not related to this fix. Can you open a new issue?
Yes, I'll open another issue.