Revert serverEnabled setting — no value over disabling the extension#651
Closed
Revert serverEnabled setting — no value over disabling the extension#651
Conversation
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix duplicate server handlers on concurrent restarts
Add Mar 4, 2026
serverEnabled setting support from upstream template
The serverEnabled setting doesn't provide meaningful value over simply disabling the extension. Reverting all changes from the previous commit. Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
Copilot
AI
changed the title
Add
Revert serverEnabled setting — no value over disabling the extension
Mar 4, 2026
serverEnabled setting support from upstream template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The upstream template PR (#259) introduced a
serverEnabledsetting to allow disabling the language server without disabling the extension. After review, this setting doesn't provide meaningful value for this extension — disabling the extension itself achieves the same effect.This reverts the
serverEnabledimplementation that was added in the initial commit on this branch:package.json— Removedblack-formatter.serverEnabledconfiguration propertysrc/common/settings.ts— RemovedgetServerEnabled()andserverEnabledfrom config change watch listsrc/extension.ts— Removed early-exit server stop logic gated onserverEnabledpackage.nls.json+ locale files — Removedsettings.serverEnabled.descriptionentriessettings.unit.test.ts— Removed associated testsThe other part of #259 (concurrency guard with
isRestarting+restartTimerdebounce) was already present in this repo and remains unchanged.Original prompt
This section details on the original issue you should resolve
<issue_title>Template Sync: Fix duplicate server handlers on concurrent restarts</issue_title>
<issue_description>### 🔄 Template Sync Required
Changes from the upstream vscode-python-tools-extension-template have not yet been fully incorporated into this repository.
Source PR
Summary
PR #259 introduced two sets of changes to the template:
Concurrency guard with debounce (
isRestartingflag +restartTimer) inrunServer()to prevent duplicate server spawning when multiple concurrent restarts are triggered. This part is already present in this repo.serverEnabledsetting support — a newblack-formatter.serverEnabledboolean configuration that allows users (or workspace configs) to disable the formatter's language server entirely. When set tofalse, the running server is gracefully stopped. This part has not been incorporated into this repository.Files with missing changes
src/common/settings.ts— Missing thegetServerEnabled()utility function andserverEnabledin thecheckIfConfigurationChangedlist:src/extension.ts— Missing thegetServerEnabledcheck insiderunServer()that gracefully stops the server when disabled:package.json— Missing theblack-formatter.serverEnabledconfiguration property declaration (needed for VS Code to surface the setting in the UI):Suggested fix
src/common/settings.ts— AddserverEnabledtocheckIfConfigurationChangedand thegetServerEnabledexport:export function checkIfConfigurationChanged(e: ConfigurationChangeEvent, namespace: string): boolean { const settings = [ `\$\{namespace}.args`, `\$\{namespace}.cwd`, `\$\{namespace}.path`, `\$\{namespace}.interpreter`, `\$\{namespace}.importStrategy`, `\$\{namespace}.showNotifications`, + `\$\{namespace}.serverEnabled`, `\$\{namespace}.serverTransport`, ]; const changed = settings.map((s) => e.affectsConfiguration(s)); return changed.includes(true); } +export function getServerEnabled(namespace: string): boolean { + const config = getConfiguration(namespace); + return config.get(boolean)('serverEnabled', true); +}src/extension.ts— ImportgetServerEnabledand add the early-exit branch inrunServer():import { checkIfConfigurationChanged, getWorkspaceSettings, + getServerEnabled, logDefaultFormatter, logLegacySettings, } from './common/settings';isRestarting = true; try { + if (!getServerEnabled(serverId)) { + if (lsClient) { + try { + await lsClient.stop(); + } catch (ex) { + traceError(`Server: Stop failed: \$\{ex}`); + } + lsClient = undefined; + } + return; + } + const projectRoot = await getProjectRoot();package.json— Add theserverEnabledproperty tocontributes.configuration.properties(using the Black-specific namespaceblack-formatter):Also add a corresponding entry to
package.nls.jsonand allpackage.nls.*.jsonlocale files.Files skipped
src/common/constants.ts—LS_SERVER_RESTART_DELAYalready present in this repo.src/common/server.ts— ...🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.