vscode-kotlin icon indicating copy to clipboard operation
vscode-kotlin copied to clipboard

Improved region-comment folding support

Open Tanja-4732 opened this issue 3 years ago • 2 comments

Motivation

Having the same code folding syntax supported in Android Studio and VS Code would be great.
It's just really annoying that they're not the same.

Description

Code like

//region Some name here
foo()
//endregion

is understood by Android Studio, and VS Code (if set to or Rust using the RLS extension). This means it's possible for VS Code to understand this syntax, if the language extension supports it.

However, when VS Code uses this extension to handle Kotlin, the code can no longer be folded.

Proposed change

Accept both

// #region regionName
vsCodeStyle()
// #endregion

and

//region regionName
androidStudioStyle()
//endregion

syntax comments.

If I have time, I might open a PR myself, let me know if that'd help.
Edit: I might have to look for the correct repository to submit this issue to. Searching the code, I'm not sure this extension handles code folding itself. Should this be changed in this extension or in the Language-Server?

TL;DR

// #region regionName & // #endregion works, but //region regionName & //endregion doesn't;
please fix/improve

Tanja-4732 avatar Sep 29 '21 15:09 Tanja-4732

I just found https://github.com/fwcd/kotlin-language-server/blob/04da62f9dcbb937cb981a9d2cc14bf346a15eadf/grammars/kotlin.configuration.json (other repository), which appears to be the file which needs to be modified.

I intend to leave this issue open, until the fix is available in this extension; let me know if that's a problem

Tanja-4732 avatar Sep 29 '21 15:09 Tanja-4732

https://github.com/fwcd/kotlin-language-server/pull/307 is now merged :rocket: :tada:

Tanja-4732 avatar Oct 01 '21 16:10 Tanja-4732