feat(folding): Asynchronous folding
This commit is contained in:
parent
ace85c6a5a
commit
61c737be3a
6 changed files with 35 additions and 2 deletions
|
@ -23,6 +23,9 @@ Changelog structure reference:
|
|||
#### Error diagnostics (NEW)
|
||||
- Basic diagnostics info from LSP (mostly just trivial syntax errors)
|
||||
|
||||
#### Code Folding
|
||||
- Asynchronous folding (Enable it in the settings!)
|
||||
|
||||
### Fixed
|
||||
|
||||
#### Syntax Highlighting
|
||||
|
|
|
@ -42,7 +42,7 @@ dependencies {
|
|||
// - https://github.com/ballerina-platform/lsp4intellij/pull/327 (with the extra fixes)
|
||||
// - https://github.com/ballerina-platform/lsp4intellij/pull/331
|
||||
// Are merged.
|
||||
implementation("com.github.FalsePattern:lsp4intellij:783363963f")
|
||||
implementation("com.github.FalsePattern:lsp4intellij:db4914dd37")
|
||||
}
|
||||
|
||||
intellij {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.falsepattern.zigbrains.ide;
|
||||
|
||||
import com.falsepattern.zigbrains.settings.AppSettingsState;
|
||||
import org.eclipse.lsp4j.FoldingRange;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -21,4 +22,9 @@ public class ZigFoldingRangeProvider extends LSPFoldingRangeProvider {
|
|||
default -> "...";
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean async() {
|
||||
return AppSettingsState.getInstance().asyncFolding;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public class AppSettingsComponent {
|
|||
private final JPanel myMainPanel;
|
||||
private final TextFieldWithBrowseButton zlsPathText = new TextFieldWithBrowseButton();
|
||||
private final TextFieldWithBrowseButton zlsConfigPathText = new TextFieldWithBrowseButton();
|
||||
private final JBCheckBox asyncFoldingCheckBox = new JBCheckBox();
|
||||
private final JBCheckBox debugCheckBox = new JBCheckBox();
|
||||
private final JBCheckBox messageTraceCheckBox = new JBCheckBox();
|
||||
private final JBCheckBox increaseTimeouts = new JBCheckBox();
|
||||
|
@ -44,6 +45,8 @@ public class AppSettingsComponent {
|
|||
.addLabeledComponent(new JBLabel("ZLS config path (leave empty to use default): "),
|
||||
zlsConfigPathText, 1, false)
|
||||
.addLabeledComponent(new JBLabel("Increase timeouts"), increaseTimeouts, 1, false)
|
||||
.addLabeledComponent(new JBLabel("Asynchronous code folding ranges: "),
|
||||
asyncFoldingCheckBox, 1, false)
|
||||
.addSeparator()
|
||||
.addComponent(new JBLabel("Developer settings" +
|
||||
" (only usable when the IDE was launched with " +
|
||||
|
@ -86,6 +89,14 @@ public class AppSettingsComponent {
|
|||
increaseTimeouts.setSelected(state);
|
||||
}
|
||||
|
||||
public boolean getAsyncFolding() {
|
||||
return asyncFoldingCheckBox.isSelected();
|
||||
}
|
||||
|
||||
public void setAsyncFolding(boolean state) {
|
||||
asyncFoldingCheckBox.setSelected(state);
|
||||
}
|
||||
|
||||
public boolean getDebug() {
|
||||
return debugCheckBox.isSelected();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,12 @@ public class AppSettingsConfigurable implements Configurable {
|
|||
@Override
|
||||
public boolean isModified() {
|
||||
var settings = AppSettingsState.getInstance();
|
||||
boolean modified = zlsSettingsModified(settings);
|
||||
modified |= settings.asyncFolding != appSettingsComponent.getAsyncFolding();
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean zlsSettingsModified(AppSettingsState settings) {
|
||||
boolean modified = !settings.zlsPath.equals(appSettingsComponent.getZLSPath());
|
||||
modified |= !settings.zlsConfigPath.equals(appSettingsComponent.getZLSConfigPath());
|
||||
modified |= settings.debug != appSettingsComponent.getDebug();
|
||||
|
@ -50,12 +56,16 @@ public class AppSettingsConfigurable implements Configurable {
|
|||
@Override
|
||||
public void apply() {
|
||||
var settings = AppSettingsState.getInstance();
|
||||
boolean reloadZLS = zlsSettingsModified(settings);
|
||||
settings.zlsPath = appSettingsComponent.getZLSPath();
|
||||
settings.zlsConfigPath = appSettingsComponent.getZLSConfigPath();
|
||||
settings.asyncFolding = appSettingsComponent.getAsyncFolding();
|
||||
settings.debug = appSettingsComponent.getDebug();
|
||||
settings.messageTrace = appSettingsComponent.getMessageTrace();
|
||||
settings.increaseTimeouts = appSettingsComponent.getIncreaseTimeouts();
|
||||
ZLSStartupActivity.initZLS();
|
||||
if (reloadZLS) {
|
||||
ZLSStartupActivity.initZLS();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,8 +74,10 @@ public class AppSettingsConfigurable implements Configurable {
|
|||
appSettingsComponent.setZLSPath(settings.zlsPath);
|
||||
appSettingsComponent.setZLSConfigPath(settings.zlsConfigPath);
|
||||
appSettingsComponent.setDebug(settings.debug);
|
||||
appSettingsComponent.setAsyncFolding(settings.asyncFolding);
|
||||
appSettingsComponent.setMessageTrace(settings.messageTrace);
|
||||
appSettingsComponent.setIncreaseTimeouts(settings.increaseTimeouts);
|
||||
appSettingsComponent.setAsyncFolding(settings.asyncFolding);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,6 +31,7 @@ public final class AppSettingsState implements PersistentStateComponent<AppSetti
|
|||
public String zlsPath = "";
|
||||
public String zlsConfigPath = "";
|
||||
public boolean debug = false;
|
||||
public boolean asyncFolding = true;
|
||||
public boolean messageTrace = false;
|
||||
public boolean increaseTimeouts = false;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue