Skip to content

Commit

Permalink
Add bracket indentation semantics to (* *)
Browse files Browse the repository at this point in the history
Background: ionide/ionide-fsgrammar#209 and ionide/ionide-fsgrammar#210

This comes from a comment regarding a pull request that I made on the
ionide-fsgrammar repository, which removes the `(* *)` bracket pair from
the "brackets" field of language-configuration.json. One issue with
doing this is that we lose the bracket-like indentation that VSCode
provides by default for all bracket pairs. This pull request re-adds the
same semantics to the indentation rules.

In other words, when I hit Enter in the following configuration,
cursor location represented by the white block:

    (*█*)

It should indent the cursor and then put the `*)` on the next line
with the same indentation level as the `(*` as follows:

    (*
        █
    *)

---

When I hit Enter with an unaccompanied `(*`:

    (*█

It should simply indent as follows:

    (*
        █

---

Lastly, an unaccompanied `*)` should outdent. That is,

        *)█

should become

    *)█
  • Loading branch information
mbottini committed Apr 1, 2024
1 parent b0d2ebe commit 2b507b1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Components/LanguageConfiguration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ module LanguageConfiguration =
jsOptions<IndentationRule> (fun o ->
o.increaseIndentPattern <-
Regex(
"""^(\s*(module|type|let|static member|member)\b.*=\s*)$|^(\s*(with get|and set)\b.*=.*)$|^(\s*(if|elif|then|else|static member|member)).*$"""
"""^(\s*(module|type|let|static member|member)\b.*=\s*)$|^(\s*(with get|and set)\b.*=.*)$|^(\s*(if|elif|then|else|static member|member|\(\*)).*$"""
)

o.decreaseIndentPattern <- Regex("""^(\s*(else|elif|and)).*$"""))
o.decreaseIndentPattern <- Regex("""^(\s*(else|elif|and|\*\))).*$"""))

let setLanguageConfiguration (triggerNotification: bool) =
// Config always setted
Expand Down

0 comments on commit 2b507b1

Please sign in to comment.