Skip to content

Error trying to indent when adding new line #336

@rinfz

Description

@rinfz

Description

I receive the following error when hitting RET after an open bracket: fsharp--compute-indentation-open-bracket: End position is smaller than start position.

Repro steps

Given the code

let f () =
    Response.ofHtml(

Press RET so we can add the closing bracket on the following line. Cursor resets to col 0 on that line and the error is added to messages buffer.

Same behaviour when trying to build nested lists within ofHtml call:

let f () =
    Response.ofHtml(
        Templates.html5 "en" [

Press RET after [ will raise the error too.

Expected behavior

Cursor moves to next line with correct indentation applied: (+ (current-indentation) fsharp-indent-offset).

Actual behavior

Cursor moved to next line and no indentation is added. An error is raised.

Known workarounds

Comment out the call to (fsharp-goto-initial-line) at the end of fsharp--compute-indentation-open-bracket.

If you include that call, it will cause the cursor to move to col 0 on the Response.ofHtml( line and the cursor position will be before the bracket position causing an error. Without it, the cursor stays on the position of the bracket and can move to the next line correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions