Question
· Jan 24

VSCode Dot Syntax Indentation

In VS Code using the InterSystems ObjectScript extensions, I'd like the indentation applied to match that of IRIS Studio. Specifically for comments and dot syntax, I'd like pressing enter (carriage return) to preserve the current dot depth and same comment beginning.

In IRIS Studio after changing the indentation settings to custom using " \t.#/;" without quotes (note the leading space), the behaviour looks like this:

And after pressing enter the leading comment is preserved:

For dot indented code:

After pressing enter the dot depth is preserved:

If I do the same thing in VS Code the carriage return takes me back to the beginning of the line (after the tab). I could almost live with this for the comments, but if code was indented by 6 dots, I can see mistakes creeping in if developers have to manually apply the dots.

Is there a object script language setting I can alter to reinstate the IRIS Studio behaviour in VS Code?

Product version: IRIS 2022.1
$ZV: IRIS for Windows (x86-64) 2022.1.4 (Build 812_0_22849) Wed Nov 8 2023 17:54:43 EST
Discussion (3)2
Log in or sign up to continue

Hi @Mathew Rimmington, this exact question was asked in a GitHub discussion a few weeks ago. To summarize my answer there, this isn't easy to add because the text that gets added on enter (besides indentation) is static. It acn't be generated from the regular expression used to match the previous line, so I couldn't dynamically add the correct number of dots. My recommendation is to use modern brace syntax instead of legacy dot syntax.

Hi Brett, thanks for getting back to me with an answer. As we have thousands of routines containing dot syntax I couldn't really leave this without a solution. For now we've built our own simple extension to implement OnTypeFormattingEditProvider. See https://vshaxe.github.io/vscode-extern/vscode/OnTypeFormattingEditProvider.html.

In our case all the method implementation needs to do is look at the previous line, assess how many dots the line begins with and populate the same on the new line. I can appreciate the difficulty you'll have with making this work for all scenarios in Object Script though.