microsoft/vscode · error · InvalidContextError

Invalid context at character ${index}:\n${ctxText}

Error message

Invalid context at character ${index}:\n${ctxText}

What it means

Error "Invalid context at character ${index}:\n${ctxText}" thrown in microsoft/vscode.

Source

Thrown at extensions/copilot/src/extension/tools/node/applyPatch/parser.ts:400

					);
				}

				if (i > 0 && match) {
					match.fuzz |= Fuzz.MergedOperatorSection;
				}
			}

			if (!match) {
				const ctxText = nextSection.nextChunkContext.join('\n');
				if (nextSection.eof) {
					throw new InvalidContextError(`Invalid EOF context at character ${index}:\n${ctxText}`, text, 'invalidContext-eof');
				} else {
					const kindForTelemetry = ctxText.match(/^\\t/) ?
						'invalidContext-maybeInvalidTab' :
						ctxText.match(/^\\\t/) ?
							'invalidContext-maybeEscapedTab' :
							'invalidContext';
					throw new InvalidContextError(`Invalid context at character ${index}:\n${ctxText}`, text, kindForTelemetry);
				}
			}
			this.fuzz += match.fuzz;
			const srcIndentStyle = guessIndentation(
				nextSection.chunks.flatMap(c => c.insLines).concat(nextSection.nextChunkContext),
				targetIndentStyle.tabSize,
				targetIndentStyle.insertSpaces
			);

			const matchedLineIndent = computeIndentLevel2(fileLines[match.line], targetIndentStyle.tabSize);
			const normalizedNextChunkContext = (match.fuzz & Fuzz.NormalizedExplicitTab)
				? replace_explicit_tabs(nextSection.nextChunkContext[0])
				: (match.fuzz & Fuzz.NormalizedExplicitNL)
					? replace_explicit_nl(nextSection.nextChunkContext[0])
					: nextSection.nextChunkContext[0];
			const srcLineIndent = nextSection.nextChunkContext && nextSection.nextChunkContext.length > 0 ?
				computeIndentLevel2(normalizedNextChunkContext, srcIndentStyle.tabSize) : 0;
			const additionalIndentation = getIndentationChar(targetIndentStyle).repeat(Math.max(0, matchedLineIndent - srcLineIndent));

View on GitHub (pinned to a94b963a32)

When it happens

Trigger: Thrown at extensions/copilot/src/extension/tools/node/applyPatch/parser.ts:400 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/vscode@a94b963a32 (2026-08-12). Data as JSON: /api/errors/0d88d4aa4c143869. Report an issue: GitHub.