mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] code_generator: stop matching other variables prefix
Previously, we would replace block declarations in some contexts with
the variable alone, and decalres the variable higher in the generated
code. Issues arise because whe sometimes try to replace "let b2" with
"b2" but end up matching "let b20" which is incorrect.
This commit fixes that by adding a space to the text that we are trying
to match ("let b2 " won't match "let b20")
This commit is contained in:
committed by
Géry Debongnie
parent
68684a9a45
commit
287a6d5ac4
@@ -673,7 +673,7 @@ export class CodeGenerator {
|
||||
const children = block!.children.slice();
|
||||
let current = children.shift();
|
||||
for (let i = codeIdx; i < code.length; i++) {
|
||||
if (code[i].trimStart().startsWith(`let ${current!.varName}`)) {
|
||||
if (code[i].trimStart().startsWith(`let ${current!.varName} `)) {
|
||||
code[i] = code[i].replace(`let ${current!.varName}`, current!.varName);
|
||||
current = children.shift();
|
||||
if (!current) break;
|
||||
@@ -768,7 +768,7 @@ export class CodeGenerator {
|
||||
const children = block!.children.slice();
|
||||
let current = children.shift();
|
||||
for (let i = codeIdx; i < code.length; i++) {
|
||||
if (code[i].trimStart().startsWith(`let ${current!.varName}`)) {
|
||||
if (code[i].trimStart().startsWith(`let ${current!.varName} `)) {
|
||||
code[i] = code[i].replace(`let ${current!.varName}`, current!.varName);
|
||||
current = children.shift();
|
||||
if (!current) break;
|
||||
@@ -912,7 +912,7 @@ export class CodeGenerator {
|
||||
const children = block!.children.slice();
|
||||
let current = children.shift();
|
||||
for (let i = codeIdx; i < code.length; i++) {
|
||||
if (code[i].trimStart().startsWith(`let ${current!.varName}`)) {
|
||||
if (code[i].trimStart().startsWith(`let ${current!.varName} `)) {
|
||||
code[i] = code[i].replace(`let ${current!.varName}`, current!.varName);
|
||||
current = children.shift();
|
||||
if (!current) break;
|
||||
|
||||
Reference in New Issue
Block a user