robotcode icon indicating copy to clipboard operation
robotcode copied to clipboard

[ENHANCEMENT] Add onEnter rule to split a long line

Open mardukbp opened this issue 2 years ago • 2 comments

Is your enhancement request related to a problem? Please describe.

Long lines can be split in several lines, each of which must start with an ellipsis (...). Manually aligning the lines to the current indentation level and inserting the ellipsis is a waste of time.

Describe the solution you'd like

Add an onEnter Rule in the language-configuration.json file.

  "onEnterRules": [
    {
      "beforeText": "^\\s*\\.\\.\\.",
      "action": { "indent": "none", "appendText": "...  " }
    }
  ]

Describe alternatives you've considered

None easier than this proposal.

Additional context

Use cases for this rule:

*** Settings ***
Library    Browser

*** Variables ***
&{dict}  first=John
    ...  last=Smith
    ...  street=Sesame St.
    ...  phone=12345

*** Keywords ***
My Keyword
    [Documentation]  Super long documentation
                ...  that helps the user

    [Arguments]  ${first super long argument}
            ...  ${second super long argument}
            ...  ${third super long argument}

    Evaluate JavaScript
    ...  function f() {
    ...      return 3;
    ...  }

mardukbp avatar Sep 13 '22 14:09 mardukbp

You can also use robotframework-tidy ;-) Just install it and use "Format Document" . This also works for RobotFramework > 5

But I will look at this. And there is also a Language Server Feature named Document on Type Formatting Request, that maybe helps to implement this.

d-biehl avatar Sep 13 '22 15:09 d-biehl

robotidy is not a solution. You still have to type the three dots plus two spaces afterwards and robotidy will align the lines. I did not know about that LSP feature. Maybe it can be implemented like that. I just thought that an onEnter rule gets the job done with least effort ;)

mardukbp avatar Sep 13 '22 16:09 mardukbp