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

Moving cursor across folded code should not automatically unfold #246

Open
Adomas-beep-boop-maggots opened this issue Mar 31, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@Adomas-beep-boop-maggots

This is a dupe from another repo, dance has a very similar problem:
aioutecism/amVim-for-VSCode#184
All I know that the vscode API didnt let extensions to determine if a cursor position is within a fold, but that issue really old and perhaps they fixed it? I'm not experienced in javascript or vscode extension development so i dont know how to search for these API changes (feel free to close this issue if the API fix still didnt happen btw).
Perhaps there is a way to make a hack or use built in cursor up/down/left/right to fix this issue without an API change?

@forivall
Copy link

forivall commented Feb 10, 2024

With the current capabilities of the vscode extension api, I think the best way to solve this would be with a custom folding range provider that wraps existing folding range providers, or just does a good enough job to use instead of the builtin folding range providers. I stumbled on vscode-better-folding which kindof does that, although, i think in dance's case, it would be best to utilize tree-sitter for the folding range provider, as tree-sitter is baked into helix, and there's some use here too (though i havent figured out how to get tree-sitter working with dance 😅)

edit: Here's my current workaround:

keybindings.json

  { "key": "j", "command": "dance.run",             "when": "editorTextFocus && dance.mode == 'normal' && !editorHasSelection && !editorHasMultipleSelections", "args": {
    "code": [
      "if (repetitions > 1) {",
      "  await vscode.commands.executeCommand('dance.select.down.jump', { count: repetitions })",
      "} else {",
      "  vscode.commands.executeCommand('cursorDown')",
      "}"
    ] } },
  { "key": "k", "command": "dance.run",             "when": "editorTextFocus && dance.mode == 'normal' && !editorHasSelection && !editorHasMultipleSelections", "args": {
    "code": [
      "if (repetitions > 1) {",
      "  await vscode.commands.executeCommand('dance.select.up.jump', { count: repetitions })",
      "} else {",
      "  vscode.commands.executeCommand('cursorUp')",
      "}"
    ] } },

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

No branches or pull requests

3 participants