Skip to content

Commit 200386a

Browse files
committed
Fix loading preference default for linked editing
Allows for customizing the default preference value with a plugin_customization.ini
1 parent fb7adfe commit 200386a

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

org.eclipse.lsp4e/src/org/eclipse/lsp4e/operations/linkedediting/LSPLinkedEditingBase.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.util.Optional;
1717
import java.util.concurrent.CompletableFuture;
1818

19+
import org.eclipse.core.runtime.preferences.DefaultScope;
1920
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
2021
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
2122
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
@@ -33,14 +34,19 @@
3334

3435
public class LSPLinkedEditingBase implements IPreferenceChangeListener {
3536
public static final String LINKED_EDITING_PREFERENCE = "org.eclipse.ui.genericeditor.linkedediting"; //$NON-NLS-1$
37+
private static final boolean LINKED_EDITING_ACTIVE_DEFAULT = true;
3638

3739
private @Nullable CompletableFuture<List<LinkedEditingRanges>> request;
3840
protected boolean fEnabled;
3941

4042
protected void install() {
41-
IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(LanguageServerPlugin.PLUGIN_ID);
42-
preferences.addPreferenceChangeListener(this);
43-
this.fEnabled = preferences.getBoolean(LINKED_EDITING_PREFERENCE, true);
43+
IEclipsePreferences defaultScopePreferences = DefaultScope.INSTANCE.getNode(LanguageServerPlugin.PLUGIN_ID);
44+
boolean defaultValue = defaultScopePreferences.getBoolean(LINKED_EDITING_PREFERENCE, LINKED_EDITING_ACTIVE_DEFAULT);
45+
46+
IEclipsePreferences instanceScopePreferences = InstanceScope.INSTANCE.getNode(LanguageServerPlugin.PLUGIN_ID);
47+
instanceScopePreferences.addPreferenceChangeListener(this);
48+
49+
this.fEnabled = instanceScopePreferences.getBoolean(LINKED_EDITING_PREFERENCE, defaultValue);
4450
}
4551

4652
protected void uninstall() {

0 commit comments

Comments
 (0)