From 8d4dd6d357d9af88d79553db7bd4d2828b01e5ee Mon Sep 17 00:00:00 2001 From: Michael Bottini Date: Sun, 31 Mar 2024 19:18:15 -0700 Subject: [PATCH] Add bracket indentation semantics to (* *) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Background: ionide/ionide-fsgrammar#209 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. 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 *)█ --- src/Components/LanguageConfiguration.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/LanguageConfiguration.fs b/src/Components/LanguageConfiguration.fs index 1c7afd73..d7353a27 100644 --- a/src/Components/LanguageConfiguration.fs +++ b/src/Components/LanguageConfiguration.fs @@ -12,10 +12,10 @@ module LanguageConfiguration = jsOptions (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 @@ -35,7 +35,7 @@ module LanguageConfiguration = rule.beforeText <- Regex("^\s*\/{3}.*$")) - |] + |] )) let activateSmartIndent = "FSharp.smartIndent" |> Configuration.get false