{"record":{"id":"03f63bd03c1af496","repo":"neoclide/coc.nvim","slug":"pattern-n-not-supported","errorCode":null,"errorMessage":"pattern \\n not supported","messagePattern":"pattern \\\\n not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/snippets/util.ts","lineNumber":81,"sourceCode":"const namedReferenceRe = /\\(\\?P=(\\w+)\\)/\nconst regex = new RegExp(`${commentRe.source}|${stringStartRe.source}|${namedCaptureRe.source}|${namedReferenceRe.source}`, 'g')\n\n/**\n * Convert python regex to javascript regex,\n * throw error when unsupported pattern found\n */\nexport function convertRegex(str: string): string {\n  if (str.indexOf('\\\\z') !== -1) {\n    throw new Error('pattern \\\\z not supported')\n  }\n  if (str.indexOf('(?s)') !== -1) {\n    throw new Error('pattern (?s) not supported')\n  }\n  if (str.indexOf('(?x)') !== -1) {\n    throw new Error('pattern (?x) not supported')\n  }\n  if (str.indexOf('\\n') !== -1) {\n    throw new Error('pattern \\\\n not supported')\n  }\n  if (conditionRe.test(str)) {\n    throw new Error('pattern (?id/name)yes-pattern|no-pattern not supported')\n  }\n  return str.replace(regex, (match, p1) => {\n    if (match.startsWith('(?#')) return ''\n    if (match.startsWith('(?P<')) return '(?' + match.slice(3)\n    if (match.startsWith('(?P=')) return `\\\\k<${p1}>`\n    // if (match == '\\\\A') return '^'\n    return '^'\n  })\n}\n\n/**\n * Action code from context or option\n */\nexport function getAction(opt: { actions?: { [key: string]: any } } | undefined, action: UltiSnipsAction): string | undefined {\n  if (!opt || !opt.actions) return undefined","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/snippets/util.ts#L63-L99","documentation":"A newline inside a snippet transform regex is not representable in the JS conversion, which expects a single-line pattern string. convertRegex rejects it early rather than producing a broken regex. Raised while parsing transform patterns in snippet bodies.","triggerScenarios":"A snippet transform regex containing a literal \\n or an actual newline character inside the pattern.","commonSituations":"Multi-line patterns pasted from Python snippet definitions; template strings spanning lines in generated snippets.","solutions":["Remove the newline from the pattern.","Replace the newline matcher with a character-class equivalent like [\\s\\S] or \\s.","Restructure the transform so it matches within a single line.","Validate the snippet string contains no raw newlines inside ${.../regex/.../}."],"exampleFix":"// before\n'${1/foo\\nbar/x/}'\n// after\n'${1/foo\\\\sbar/x/}'","handlingStrategy":"validation","validationCode":"function regexIsSingleLine(pattern: string): boolean {\n  return !pattern.includes('\\n')\n}","typeGuard":"null","tryCatchPattern":"try {\n  let js = convertRegex(pattern)\n} catch (e) {\n  if (String(e.message).includes('\\\\n')) pattern = pattern.replace(/\\n/g, '\\\\s')\n}","preventionTips":["Keep transform patterns on one line.","Use \\s or [\\s\\S] instead of literal newlines.","Avoid template literals spanning lines inside snippet bodies.","Check generated snippets for raw newlines."],"tags":["snippets","regex","transform"],"backgroundTag":"unsupported-regex-pattern","analyzedSha":"50e974d9692461a69147d5cab146a8d3e439abe4","analyzedAt":"2026-08-31T11:17:23.966Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}