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

#region Support #33

Closed
0xLeon opened this issue Nov 10, 2017 · 7 comments
Closed

#region Support #33

0xLeon opened this issue Nov 10, 2017 · 7 comments
Assignees
Labels
feature-request Request for new features or functionality
Milestone

Comments

@0xLeon
Copy link

0xLeon commented Nov 10, 2017

I know it's not usual in the Python environment, but adding support for regions, which are in turn supported by VSCode since 1.17[1], would be a really nice feature. Often I work with large classes which have a lot of methods, which are grouped already, but being able to completely fold all regions I'm not working on right now would make for a smoother editing experience I think.

[1] https://code.visualstudio.com/updates/v1_17#_folding-regions

@DonJayamanne DonJayamanne added the feature-request Request for new features or functionality label Nov 14, 2017
@MikhailArkhipov MikhailArkhipov self-assigned this Jan 5, 2018
@MikhailArkhipov
Copy link

MikhailArkhipov commented Jan 5, 2018

VS Code supports Python folding out of the box

image

See also default Python config file in (Windows)
C:\Program Files\Microsoft VS Code\resources\app\extensions\python

	"folding": {
		"offSide": true,
		"markers": {
			"start": "^\\s*#region\\b",
			"end": "^\\s*#endregion\\b"
		}
	}

You need to hover over margin to see the marker. It is controlled by

image

@lpravda
Copy link

lpravda commented Mar 13, 2018

works fine until you format the document. then '#region' becomes '# region' and the functionality does not work.

@brettcannon
Copy link
Member

@lpravda can you file a separate issue for this? I assume you have formatOnSave turned on?

@B3Bo1d
Copy link

B3Bo1d commented Mar 14, 2018

when i use Shift+Alt+F, "#region" -> "# region"

@ueqt
Copy link

ueqt commented Mar 28, 2018

@lpravda @B3Bo1d
you can change
C:\Program Files\Microsoft VS Code\resources\app\extensions\python\language-configuration.json(in windows) or
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/extensions/python/language-configuration.json(in mac) as follows, and reopen vscode then it should works for "# region"

	"folding": {
		"offSide": true,
		"markers": {
			"start": "^\\s*#\\s*region\\b",
			"end": "^\\s*#\\s*endregion\\b"
		}
	}

@lpravda
Copy link

lpravda commented Mar 28, 2018

works like a charm :)

brettcannon added a commit to brettcannon/vscode that referenced this issue Mar 28, 2018
Automatic formatting inserts a space between the comment marker `#` and text in the Python extension, so without the allowance for whitespace then `"editor.formatOnType": true` breaks all region markers.

Closes microsoft/vscode-python#1073 and microsoft/vscode-python#33
@brettcannon
Copy link
Member

This landed upstream in VS Code 4 minutes ago, so should be able to validate this in a day or so in the Insiders build.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

7 participants