fsharp / fsharp/emacs-fsharp-mode

Error trying to indent when adding new line

Open
#336 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Emacs Lisp
Stars
215
Forks
65
PR merge metrics
No merged PRs in 30d

Description

### 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.