Skip to content

bug: component browser: insert double-indents when the cursor is already indented #329

Open

Description

@eFAILution

Bug summary

Insert puts the generated text at the cursor as-is, and that text already carries its own indent. With the cursor on an indented empty line, which is where you'd normally be after pressing Enter under include:, only the first line gets the extra indent. inputs: ends up at the same column as the -, which is invalid YAML.

Steps to reproduce

  1. Open a file with include: and put the cursor on the next line, indented two spaces.
  2. Run GitLab CI: Browse Components, open Details on any component with inputs and tick a few.
  3. Click Insert Component.

Expected behavior

The include lines up under include: no matter where the cursor sits on the line.

Actual behavior

The first line is indented twice, the rest once, and the YAML no longer parses.

Component context (if applicable)

Any component. Seen with components/secret-detection.

Minimal .gitlab-ci.yml snippet

include:
    - component: gitlab.com/components/secret-detection/secret-detection@2.4.0
    inputs:
      stage: "test" # optional

Extension logs

No response

Affected area

Component Browser

Extension version

0.17.19

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions