fix(folding): Miscellaneous small fixes and improvements

- Better code folding
- Race condition fix
- Another Windows fix
- Bounds check fix
This commit is contained in:
FalsePattern 2023-08-01 19:32:51 +02:00
parent bb99e9b50c
commit 1b06a7f0fc
Signed by: falsepattern
GPG key ID: FDF7126A9E124447
4 changed files with 40 additions and 2 deletions

View file

@ -18,6 +18,20 @@ Changelog structure reference:
## [Unreleased] ## [Unreleased]
### Added
#### Folding
- Better folding regions instead of just `{...}`
- `...` for the general case
- `///...` for doc comments
### Fixed
#### Folding
- Race condition on IDE startup throwing exceptions
- Folding ranges not appearing on Windows
- Typo in the bounds checking code
## [0.3.0] ## [0.3.0]
### Added ### Added

View file

@ -42,7 +42,7 @@ dependencies {
// - https://github.com/ballerina-platform/lsp4intellij/pull/327 (with the extra fixes) // - https://github.com/ballerina-platform/lsp4intellij/pull/327 (with the extra fixes)
// - https://github.com/ballerina-platform/lsp4intellij/pull/331 // - https://github.com/ballerina-platform/lsp4intellij/pull/331
// Are merged. // Are merged.
implementation("com.github.FalsePattern:lsp4intellij:f385bbb726") implementation("com.github.FalsePattern:lsp4intellij:783363963f")
} }
intellij { intellij {

View file

@ -0,0 +1,24 @@
package com.falsepattern.zigbrains.ide;
import org.eclipse.lsp4j.FoldingRange;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.wso2.lsp4intellij.contributors.LSPFoldingRangeProvider;
public class ZigFoldingRangeProvider extends LSPFoldingRangeProvider {
@Override
protected @Nullable String getCollapsedText(@NotNull FoldingRange foldingRange) {
var text = super.getCollapsedText(foldingRange);
if (text != null) {
return text;
}
var kind = foldingRange.getKind();
if (kind == null) {
return "...";
}
return switch (kind) {
case "comment" -> "///..."; //These are only done for doc comments. TODO figure out how to invoke the intellij doc renderer
default -> "...";
};
}
}

View file

@ -52,7 +52,7 @@
<!-- needed for folding support --> <!-- needed for folding support -->
<lang.foldingBuilder language="Zig" <lang.foldingBuilder language="Zig"
implementationClass="org.wso2.lsp4intellij.contributors.LSPFoldingRangeProvider" implementationClass="com.falsepattern.zigbrains.ide.ZigFoldingRangeProvider"
id="LSPFoldingRangeProvider" id="LSPFoldingRangeProvider"
order="first"/> order="first"/>