fix(folding): Miscellaneous small fixes and improvements
- Better code folding - Race condition fix - Another Windows fix - Bounds check fix
This commit is contained in:
parent
bb99e9b50c
commit
1b06a7f0fc
4 changed files with 40 additions and 2 deletions
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -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
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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 -> "...";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -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"/>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue