Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indentation of first line after bracket #330

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions fsharp-mode-structure.el
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ dedenting."
(open-bracket-pos (fsharp-nesting-level)))

(cond
((and open-bracket-pos (eq (and (looking-back "[[:space:]\n\r]+" nil t)
(match-beginning 0))
(1+ open-bracket-pos)))
fsharp-indent-offset)
;; Continuation Lines
((fsharp-continuation-line-p)
(if open-bracket-pos
Expand Down
8 changes: 8 additions & 0 deletions test/fsharp-mode-structure-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -271,3 +271,11 @@
(should (eq (fsharp--compute-indentation-relative-to-previous t) 4))
(should (eq (fsharp--compute-indentation-relative-to-previous t)
(fsharp-compute-indentation t))))))

(describe "The `fsharp-compute-indentation'"
:var ((file (concat fsharp-struct-test-files-dir "BracketIndent.fs")))
(it "indents on the first line after opening bracket"
(with-current-buffer (find-file-noselect file)
(goto-char (point-min))
(search-forward-regexp "let formatTwo = \\[\n")
(should (eq (fsharp-compute-indentation t) fsharp-indent-offset)))))