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