Skip to content

Commit

Permalink
setting to disable python file cell folding (#11737)
Browse files Browse the repository at this point in the history
  • Loading branch information
amunger committed Oct 21, 2022
1 parent c6bf05c commit a9dd309
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
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

0 comments on commit a9dd309

Please sign in to comment.