Moving cursor across folded code should not automatically unfold
Opened this issue · 1 comments
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?
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')",
"}"
] } },