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

Folding Breaks When First Line of Method Is A Multiline Comment #28631

Open
russtanner opened this issue May 3, 2024 · 3 comments
Open

Folding Breaks When First Line of Method Is A Multiline Comment #28631

russtanner opened this issue May 3, 2024 · 3 comments
Labels
bug issues reporting wrong behavior folds needs:repro We need minimal steps to reproduce the issue needs:response waiting for reply from the author treesitter

Comments

@russtanner
Copy link

Problem

Working with PHP in neovim, I found a consistent code folding issue. System is Alma Linux 8.7.

The key to replicating this issue is the position of a multiline comment.

When a multiline comment exists on the first line of a class method, when the method is folded, then copied, then pasted to another location in the file, when you attempt to fold the newly-pasted method, the entire class folds instead. At this point it is impossible to fold any single method.

public function MyFun() {
  /*
    This function will not fold properly after copying/pasting the entire method (while folded).
  */

  return 0;

}

The only solution is the insert a blank line between method name and the multiline comment. Once this is done, then the method, and all other methods now fold properly.

public function MyFun() {

  /*
    By inserting the blank line above. this method will now begin folding without folding the entire class.
  */

  return 0;

}

Steps to reproduce

  1. Create a class in PHP containing 3 methods. All methods should contain a multiline comment (/* comment (newline) comment */) as the first line in the method.
  2. Fold the second method.
  3. Copy the second method.
  4. Paste the second method to another location in the file. The method pastes in the "open" state (as expected).
  5. Fold the newly-pasted method. The entire class folds instead of only the newly-pasted method.

Expected behavior

We expect the newly-pasted method to fold without folding the entire class.

Inserting a blank line between method name and the multiline comment restores normal folding behavior.

Neovim version (nvim -v)

0.10.0-dev-2930+g47ba96a6b

Vim (not Nvim) behaves the same?

No, neovim only

Operating system/version

Alma Linux 8.7

Terminal name/version

SecureCRT 9.4.1

$TERM environment variable

xterm-256color

Installation

dnf package mgr

@russtanner russtanner added the bug issues reporting wrong behavior label May 3, 2024
@zeertzjq zeertzjq added the needs:repro We need minimal steps to reproduce the issue label May 3, 2024
@zeertzjq
Copy link
Member

zeertzjq commented May 3, 2024

Where does the folding come from? Please follow the instruction for "Steps to reproduce":

Use the provided minimal reproduction template to create a minimal configuration. After you fill it out with necessary information, run with nvim --clean -u minimal.lua.

@zeertzjq zeertzjq added the needs:response waiting for reply from the author label May 3, 2024
@russtanner
Copy link
Author

The folding comes from TreeSitter I think.

I'm not a neovim config expert by any means, but I followed instructions for installing neovim with TreeSitter, Packer, and the RosePine color scheme and have had this issue consistently from the beginning.

@github-actions github-actions bot removed the needs:response waiting for reply from the author label May 4, 2024
@clason clason added the folds label May 4, 2024
@clason
Copy link
Member

clason commented May 4, 2024

Sorry, but we need a complete, minimal, config we can test with nvim --clean -u test.lua.

@clason clason added the needs:response waiting for reply from the author label May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issues reporting wrong behavior folds needs:repro We need minimal steps to reproduce the issue needs:response waiting for reply from the author treesitter
Projects
None yet
Development

No branches or pull requests

3 participants