1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00

fix substitution losing track of document range (#1547)

This commit is contained in:
Guillermo Ruffino
2021-02-19 21:52:42 -03:00
committed by GitHub
parent 6c8ace0ce8
commit 25924ca4e8
2 changed files with 30 additions and 18 deletions

View File

@@ -4,6 +4,7 @@ import re
import esphome.config_validation as cv
from esphome import core
from esphome.const import CONF_SUBSTITUTIONS
from esphome.yaml_util import ESPHomeDataBase, make_data_base
CODEOWNERS = ['@esphome/core']
_LOGGER = logging.getLogger(__name__)
@@ -68,6 +69,14 @@ def _expand_substitutions(substitutions, value, path):
value = value[:i] + sub
i = len(value)
value += tail
# orig_value can also already be a lambda with esp_range info, and only
# a plain string is sent in orig_value
if isinstance(orig_value, ESPHomeDataBase):
# even though string can get larger or smaller, the range should point
# to original document marks
return make_data_base(value, orig_value)
return value