From 08100106cbdb94a5ba6741f5e53a6449297dcd75 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Tue, 21 Mar 2023 17:21:31 +0100 Subject: [PATCH 1/2] Add (failing) indentation test for first line after opening bracket --- test/fsharp-mode-structure-tests.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/fsharp-mode-structure-tests.el b/test/fsharp-mode-structure-tests.el index dd6653b..7792b38 100644 --- a/test/fsharp-mode-structure-tests.el +++ b/test/fsharp-mode-structure-tests.el @@ -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))))) From 64faab43fa137476a340386a56b989388b62ff0d Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Tue, 21 Mar 2023 17:22:26 +0100 Subject: [PATCH 2/2] Indentation: Handle first line after opening bracket Fixes: "End position is smaller than start position" error. --- fsharp-mode-structure.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fsharp-mode-structure.el b/fsharp-mode-structure.el index b7664fb..30376a3 100644 --- a/fsharp-mode-structure.el +++ b/fsharp-mode-structure.el @@ -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