Skip to content

[Editor] Multi-line string content is highlighted as YAML when a line is indented more than the first one #19927

Description

@marco-comi

Describe the issue

In the flow code editor, the content of a multi-line string (a block starting with | or >) should be shown as plain text, because Kestra cannot know which language it contains.

Today this is inconsistent. The content stays plain as long as all its lines have the same indentation. As soon as one line is indented more than the first line of the block, that line and the following ones are highlighted as YAML.

The file name and the task type make no difference. An Ansible playbook, a .txt file or a Python script with the same content are highlighted the same way.

Steps to reproduce

  1. Create this flow and open it in the flow code editor:
id: block_highlighting
namespace: company.team
tasks:
  - id: same_indent
    type: io.kestra.plugin.scripts.shell.Commands
    commands:
      - echo hi
    inputFiles:
      other.yml: |
        hosts: localhost
        gather_facts: false

  - id: deeper_indent
    type: io.kestra.plugin.scripts.shell.Commands
    commands:
      - echo hi
    inputFiles:
      playbook.yml: |
        - name: Output JSON to logs
          hosts: localhost
          gather_facts: false

  - id: python
    type: io.kestra.plugin.scripts.python.Script
    script: |
      for i in range(3):
          print(i)
      config: 1
  1. Look at the three blocks.

Actual behaviour

  • same_indent: the block is plain text. This is correct.
  • deeper_indent: hosts and gather_facts are highlighted as YAML keys, and false as a boolean.
  • python: the lines after print(i) are highlighted as YAML.

Expected behaviour

  • The whole content of a | or > block is shown as plain text, whatever its indentation, until the block ends.
  • The block ends where YAML says it ends: at the first non-empty line indented less than the first line of the block. From there, normal YAML highlighting continues.
  • Everything outside the block keeps its current highlighting.

Environment

Kestra Version: develop (2.1.0-SNAPSHOT)
Edition: OSS

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/frontendNeeds frontend code changesgood first issueGreat issue for new contributors

Type

Fields

Stage

In progress

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions