From 441ec0f6c5faf4e869ed46c7f7bbd6eb8c2f7fb8 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 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. 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/LanguageConfiguration.fs b/src/Components/LanguageConfiguration.fs index 1c7afd73..f1bdf650 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