{"record":{"id":"a1c955eb72951cc9","repo":"neoclide/coc.nvim","slug":"pattern-id-name-yes-pattern-no-pattern-not-suppo","errorCode":null,"errorMessage":"pattern (?id/name)yes-pattern|no-pattern not supported","messagePattern":"pattern \\(\\?id/name\\)yes-pattern\\|no-pattern not supported","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/snippets/util.ts","lineNumber":84,"sourceCode":"/**\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\n  return opt.actions[action]\n}\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/neoclide/coc.nvim/blob/50e974d9692461a69147d5cab146a8d3e439abe4/src/snippets/util.ts#L66-L102","documentation":"Python conditional patterns of the form (?(id)yes|no) are not supported by JavaScript regex, so the snippet transform converter rejects them at parse time. This prevents silently translating a conditional into an invalid or wrong JS pattern.","triggerScenarios":"A snippet transform regex containing a conditional group (?(1)...|...) or (?(name)...|...).","commonSituations":"Snippets ported from UltiSnips or Python tools that rely on conditional regex constructs.","solutions":["Rewrite the conditional using alternation and lookarounds.","Split the transform into multiple simpler transforms if possible.","Remove the conditional if the yes/no branches can be expressed by the replacement string.","Simplify the snippet to avoid the pattern entirely."],"exampleFix":"// before\n'${1/(?(1)a|b)/x/}'\n// after\n'${1/(?:^b|a)/x/}' // express with alternation/lookarounds","handlingStrategy":"validation","validationCode":"let conditionRe = /\\(\\?\\(?[\\w]+\\)?/ // rough conditional-detector\nfunction regexIsPortable(pattern: string): boolean {\n  return !/\\(\\?\\(/.test(pattern)\n}","typeGuard":"null","tryCatchPattern":"try {\n  let js = convertRegex(pattern)\n} catch (e) {\n  if (String(e.message).includes('yes-pattern')) pattern = rewriteConditional(pattern) // use alternation/lookarounds\n}","preventionTips":["Avoid (?(id)yes|no) constructs; JS regex lacks them.","Rewrite conditionals with lookaheads and alternation.","Keep snippet transforms minimal.","Test transforms against coc's converter before shipping."],"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"}