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

Puppet profile document formatting #306

Closed
Vasista-Eranki opened this issue Mar 24, 2021 · 5 comments · Fixed by #302
Closed

Puppet profile document formatting #306

Vasista-Eranki opened this issue Mar 24, 2021 · 5 comments · Fixed by #302
Assignees
Labels
enhancement New feature or request

Comments

@Vasista-Eranki
Copy link

Issue Type: Bug

Puppet profile has several resources listed. a few of the resource strings have different indentation and the collapsing of resources is getting messy due to this..
I think, the collapsing of sections shall strictly adhere the { }.

VS Code version: Code 1.54.3 (2b9aebd5354a3629c3aba0a5f5df49f43d6689f8, 2021-03-15T10:55:45.459Z)
OS version: Windows_NT x64 10.0.19041

Extensions (45)
Extension Author (truncated) Version
ng-template Ang 11.2.8
armview ben 0.4.5
hiera-eyaml bra 1.0.1
vscode-eslint dba 2.1.19
docs-yaml doc 0.2.6
gitlens eam 11.3.0
EditorConfig Edi 0.16.4
vscode-npm-script eg2 0.3.17
prettier-vscode esb 6.3.1
vscode-firefox-debug fir 2.9.2
terraform has 2.8.3
angular-essentials joh 11.0.0
Angular2 joh 11.0.0
vscode-peacock joh 3.9.1
sublime-babel-vscode jos 0.2.10
vscode-azureappservice ms- 0.21.2
vscode-azurefunctions ms- 1.3.0
vscode-azureresourcegroups ms- 0.3.0
vscode-cosmosdb ms- 0.16.0
vscode-docker ms- 1.11.0
csharp ms- 1.23.9
vscode-dotnet-runtime ms- 1.0.0
python ms- 2021.3.658691958
jupyter ms- 2021.3.619093157
remote-wsl ms- 0.54.6
azure-account ms- 0.9.7
azurecli ms- 0.5.0
powershell ms- 2021.2.2
vs-keybindings ms- 0.2.0
vscode-typescript-tslint-plugin ms- 1.3.3
team ms- 1.161.1
azurerm-vscode-tools msa 0.15.0
debugger-for-chrome msj 4.12.12
debugger-for-edge msj 1.0.15
vscode-react-native msj 1.4.1
angular2-inline nat 0.0.17
angular-console nrw 17.0.3
indent-rainbow ode 7.5.0
oracledevtools Ora 19.3.3
material-icon-theme PKi 4.5.0
puppet-vscode pup 1.1.0
ruby reb 0.28.1
vscode-yaml red 0.16.0
vscode-todo-highlight way 1.0.4
vscode-ruby win 0.28.0

(3 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspyt653:30270858
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244:30276681
pythonvsdeb440:30248342
pythonvsded773:30248341
pythonvspyt875:30259475
pythontbcf:30265426
vscoresta800cf:30276762
vspre833:30267464
vsdfh931:30275552
vshan820:30276952

@jpogran
Copy link
Contributor

jpogran commented Mar 24, 2021

Thank you for the report @Vasista-Eranki, but I do not understand what you are asking here. Can you please expand upon your request?

@Vasista-Eranki
Copy link
Author

Hello James

Consider the below example .. Notice the file resource has bad indented information for the content attribute..

image

When I try to collapse the resource, I observe the resource is not completely collapsed, instead it is collapsing the lines as shown below.

image

I'm expecting the resource collapsing shall be looking for the curly braces' matching pair { } instead of the indented lines.

@jpogran
Copy link
Contributor

jpogran commented Mar 29, 2021

Thank you for the additional detail. Unfortunately there isn't much more we can do here. If you port your example to other languages, you'll see similar behavior. It's an artifact of HERE blocks/strings (named differently depending on the language you're using), and how VS Code handles indentation.

@glennsarti
Copy link
Contributor

I wonder if we'll have to implement the code-folding Language Server feature... I did something similar for PowerShell.

The downside is I'll need to use a puppet language lexer

@glennsarti
Copy link
Contributor

glennsarti commented Mar 31, 2021

If only the ruby based puppet language implementation had a public lexer .... like the Go ones does :-)

@glennsarti glennsarti transferred this issue from puppetlabs/puppet-vscode Apr 29, 2021
glennsarti added a commit to glennsarti/puppet-editor-services that referenced this issue Apr 29, 2021
Previously the Puppet Lexer ignored whitespace and comments and did not generate
any token information. This meant it could not be used for code formatting
purposes. This commit adds a new lexer which sub-classes the original and emits
tokens for comments. Later commits can use this lexer for operations like code
folding and as-you-type formatting.

This commit also memoizes the tokens in the document store so documents do not
need to be lexed multiple times for the same version.
glennsarti added a commit to glennsarti/puppet-editor-services that referenced this issue Apr 29, 2021
Previously the Language Server dod not provide code folding hints, and the
client was left to use its defauly, typically indentation based.  This commit:

* Adds a manifest folding provider, which can extract code folding regions based
  on block comments, multiline comments and blocks of code ( { -> } and [ -> ] )
* Adds many tests to ensure that regions are detected correctly particuarly in
  nested situations, or within HEREDOC strings.
* Note that this folding is only supported on Puppet 6.3.0 and above due to
  the needed features in the Puppet Langauge tokeniser
glennsarti added a commit to glennsarti/puppet-editor-services that referenced this issue Apr 29, 2021
Now that there is a Puppet Manifest Folding provider available, the server
capabilities need to be updated so that clients know to use it. This commit:

* Creates a method on ServerCapabilities to determine if folding is supported
  by the server
* Updates the Service Capabilities to advertise the 'foldingRangeProvider'
  capavility if it is supported but not dynamic registrations
* Updates the Client Settings to send dynamic registrations
  'textDocument/foldingRange' if supported
* Adds a two new settings for Folding: Enabled and Show Last Line
* Refactors the Language Client settings to make it easier to set defaults
* Updated Server to respond to 'textDocument/foldingRange' requests

Adds many tests for the message handler and language client for the new provider
glennsarti added a commit to glennsarti/puppet-editor-services that referenced this issue Apr 29, 2021
Previously the Puppet Lexer ignored whitespace and comments and did not generate
any token information. This meant it could not be used for code formatting
purposes. This commit adds a new lexer which sub-classes the original and emits
tokens for comments. Later commits can use this lexer for operations like code
folding and as-you-type formatting.

This commit also memoizes the tokens in the document store so documents do not
need to be lexed multiple times for the same version.
glennsarti added a commit to glennsarti/puppet-editor-services that referenced this issue Apr 29, 2021
Previously the Language Server dod not provide code folding hints, and the
client was left to use its defauly, typically indentation based.  This commit:

* Adds a manifest folding provider, which can extract code folding regions based
  on block comments, multiline comments and blocks of code ( { -> } and [ -> ] )
* Adds many tests to ensure that regions are detected correctly particuarly in
  nested situations, or within HEREDOC strings.
* Note that this folding is only supported on Puppet 6.3.0 and above due to
  the needed features in the Puppet Langauge tokeniser
glennsarti added a commit to glennsarti/puppet-editor-services that referenced this issue Apr 29, 2021
Now that there is a Puppet Manifest Folding provider available, the server
capabilities need to be updated so that clients know to use it. This commit:

* Creates a method on ServerCapabilities to determine if folding is supported
  by the server
* Updates the Service Capabilities to advertise the 'foldingRangeProvider'
  capavility if it is supported but not dynamic registrations
* Updates the Client Settings to send dynamic registrations
  'textDocument/foldingRange' if supported
* Adds a two new settings for Folding: Enabled and Show Last Line
* Refactors the Language Client settings to make it easier to set defaults
* Updated Server to respond to 'textDocument/foldingRange' requests

Adds many tests for the message handler and language client for the new provider
@jpogran jpogran added the enhancement New feature or request label Apr 30, 2021
@jpogran jpogran added this to the 1.2.0 milestone Apr 30, 2021
jpogran added a commit that referenced this issue May 10, 2021
(GH-306) Add a syntax aware code folding provider
scoiatael pushed a commit to scoiatael/puppet-editor-services that referenced this issue Jan 14, 2022
Previously the Puppet Lexer ignored whitespace and comments and did not generate
any token information. This meant it could not be used for code formatting
purposes. This commit adds a new lexer which sub-classes the original and emits
tokens for comments. Later commits can use this lexer for operations like code
folding and as-you-type formatting.

This commit also memoizes the tokens in the document store so documents do not
need to be lexed multiple times for the same version.
scoiatael pushed a commit to scoiatael/puppet-editor-services that referenced this issue Jan 14, 2022
Previously the Language Server dod not provide code folding hints, and the
client was left to use its defauly, typically indentation based.  This commit:

* Adds a manifest folding provider, which can extract code folding regions based
  on block comments, multiline comments and blocks of code ( { -> } and [ -> ] )
* Adds many tests to ensure that regions are detected correctly particuarly in
  nested situations, or within HEREDOC strings.
* Note that this folding is only supported on Puppet 6.3.0 and above due to
  the needed features in the Puppet Langauge tokeniser
scoiatael pushed a commit to scoiatael/puppet-editor-services that referenced this issue Jan 14, 2022
Now that there is a Puppet Manifest Folding provider available, the server
capabilities need to be updated so that clients know to use it. This commit:

* Creates a method on ServerCapabilities to determine if folding is supported
  by the server
* Updates the Service Capabilities to advertise the 'foldingRangeProvider'
  capavility if it is supported but not dynamic registrations
* Updates the Client Settings to send dynamic registrations
  'textDocument/foldingRange' if supported
* Adds a two new settings for Folding: Enabled and Show Last Line
* Refactors the Language Client settings to make it easier to set defaults
* Updated Server to respond to 'textDocument/foldingRange' requests

Adds many tests for the message handler and language client for the new provider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants