quarto-dev / quarto

Quarto open-source scientific and technical publishing system
https://quarto.org
GNU Affero General Public License v3.0
280 stars 19 forks source link

Auto addition of `#|` messes code on "return" #426

Open mcanouil opened 2 months ago

mcanouil commented 2 months ago

This can also happen in other less reproducible situations on save. Currently, the way #| is not really reliable and most of the time causes issues rather than the opposite.

#| should only be added at the beginning of a new line.

https://github.com/quarto-dev/quarto/assets/8896044/0f4f67c6-b8a6-415b-b00e-a8c14d43da92

juliasilge commented 2 months ago

The handling for #| looks very complicated to me (although part of that is for autocompletion for the YAML options). Maybe some of that could be simplified to instead have an "OnEnter" rule in this file like:

{
    "beforeText": "^\\s*#+\\|",
    "action": { "indent": "none", "appendText": "#| " }
}

This rule results in behavior that is much better.