Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting to disable python file cell folding #11737

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,12 @@
"description": "%jupyter.configuration.jupyter.interactiveWindowMode.description%",
"default": "multiple"
},
"jupyter.pythonCellFolding": {
"type": "boolean",
"default": true,
"description": "%jupyter.configuration.jupyter.pythonCellFolding.description%",
"scope": "resource"
},
"jupyter.interactiveWindowViewColumn": {
"type": "string",
"enum": [
Expand Down
3 changes: 3 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@
"message": "Behavior of the Interactive Window. 'perFile' will create a new interactive window for every file that runs a cell. 'single' allows a single window. 'multiple' allows the creation of multiple.",
"comment": ["{Locked='perFile'}", "{Locked=\"'single'\"}", "{Locked=\"'multiple'\"}"]
},
"jupyter.configuration.jupyter.pythonCellFolding.description": {
"message": "Enable folding regions for code cells in Python files. This setting requires a reload of VS Code."
},
"jupyter.configuration.jupyter.interactiveWindowViewColumn.description": {
"message": "Where to open an Interactive Window that is not associated with a python file. 'beside' will open the interactive window to the right of the active editor. 'active' will open the interactive window in place of the active editor. 'secondGroup' will open the interactive window in the second editor group.",
"comment": ["{Locked='beside'}", "{Locked=\"'active'\"}", "{Locked=\"'secondGroup'\"}"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@ import {
} from 'vscode';
import { IExtensionSyncActivationService } from '../../platform/activation/types';
import { InteractiveInputScheme, NotebookCellScheme, PYTHON_FILE_ANY_SCHEME } from '../../platform/common/constants';
import { IExtensionContext } from '../../platform/common/types';
import { IConfigurationService, IExtensionContext } from '../../platform/common/types';
import { IDataScienceCodeLensProvider } from './types';

@injectable()
export class PythonCellFoldingProvider implements IExtensionSyncActivationService, FoldingRangeProvider {
constructor(
@inject(IDataScienceCodeLensProvider) private dataScienceCodeLensProvider: IDataScienceCodeLensProvider,
@inject(IExtensionContext) private extensionContext: IExtensionContext
@inject(IExtensionContext) private extensionContext: IExtensionContext,
@inject(IConfigurationService) private configurationService: IConfigurationService
) {}

public activate() {
this.extensionContext.subscriptions.push(
languages.registerFoldingRangeProvider([PYTHON_FILE_ANY_SCHEME], this)
);
const enabled = this.configurationService.getSettings().pythonCellFolding;
if (enabled) {
this.extensionContext.subscriptions.push(
languages.registerFoldingRangeProvider([PYTHON_FILE_ANY_SCHEME], this)
);
}
}

provideFoldingRanges(
Expand Down
1 change: 1 addition & 0 deletions src/platform/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export class JupyterSettings implements IWatchableJupyterSettings {
public jupyterCommandLineArguments: string[] = [];
public widgetScriptSources: WidgetCDNs[] = [];
public interactiveWindowMode: InteractiveWindowMode = 'multiple';
public pythonCellFolding: boolean = true;
public interactiveWindowViewColumn: InteractiveWindowViewColumn = 'secondGroup';
// Hidden settings not surfaced in package.json
public disableZMQSupport: boolean = false;
Expand Down
1 change: 1 addition & 0 deletions src/platform/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export interface IJupyterSettings {
readonly jupyterCommandLineArguments: string[];
readonly widgetScriptSources: WidgetCDNs[];
readonly interactiveWindowMode: InteractiveWindowMode;
readonly pythonCellFolding: boolean;
readonly interactiveWindowViewColumn: InteractiveWindowViewColumn;
readonly disableZMQSupport: boolean;
readonly forceIPyKernelDebugger?: boolean;
Expand Down