Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of blocks #684

Merged
merged 2 commits into from
Dec 6, 2024
Merged

Fix parsing of blocks #684

merged 2 commits into from
Dec 6, 2024

Conversation

swoboda1337
Copy link
Contributor

@swoboda1337 swoboda1337 commented Nov 29, 2024

Fix issues with parsing blocks:

  • Right now every line needs to have the same indent. However C++ code inside a lambda will have varying indents. Instead of checking for a fixed indent check that the indent is greater than or equal to the indent on the first line. End the block only when the indent decreases.
  • The rest of the editor handles tabs except for the lambda/block part. Check for both tabs and spaces.
  • Allow whitespace after the block indicator. If there is a trailing space its not treated as a block and gets parsed as yaml.

Not only does the current parsing look bad it also confuses people into thinking indents in lambdas are not allowed. I have seen people post huge lambdas in discord without a single indent.

Current HA addon, no whitespace after |-
image

Current HA addon, with whitespace after |-
image

Fixed
image

@swoboda1337 swoboda1337 changed the title Fix parsing of lambda blocks Fix parsing of blocks Dec 2, 2024
@jesserockz jesserockz merged commit f5b1c60 into esphome:main Dec 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants