On type formatting for blocks is unhelpful due to cursor placement
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- ruby, vscode
- Domain
- developer-experience, devtools
Research direction
Start by reproducing the block and method examples in VS Code with Ruby LSP's onTypeFormatting feature enabled. Check how completion places the cursor after inserting block delimiters, and verify that the cursor lands at the expected position for continuing the block or method body without arrow-key navigation.
Written by the indexing model from the issue text.
Description
Description
Ruby LSP Information
VS Code Version
1.95.3
Ruby LSP Extension Version
0.8.16
Ruby LSP Server Version
0.22.1
Ruby LSP Addons
- Ruby LSP Rails
Ruby Version
3.3.6
Ruby Version Manager
custom
Installed Extensions
Click to expand
- amx-netlinx (0.6.1)
- better-toml (0.3.2)
- copy-text (0.4.9)
- cpptools (1.22.11)
- csharp (2.55.29)
- elixir-ls (0.24.2)
- gitlens (16.0.5)
- go (0.42.1)
- haml (1.4.1)
- isort (2023.10.1)
- material-icon-theme (5.15.0)
- platformio-ide (3.3.3)
- postcss (2.0.0)
- python (2024.20.0)
- ruby-lsp (0.8.16)
- rust-analyzer (0.3.2212)
- vscode-ansi (1.1.7)
- vscode-dotnet-runtime (2.2.3)
- vscode-eslint (3.0.10)
- vscode-npm-script (0.3.29)
- vscode-projects-plus (1.24.0)
- vscode-zipfs (3.0.0)
Ruby LSP Settings
Click to expand
Workspace
{}
User
{
"enabledFeatures": {
"codeActions": true,
"diagnostics": true,
"documentHighlights": true,
"documentLink": true,
"documentSymbols": true,
"foldingRanges": true,
"formatting": true,
"hover": true,
"inlayHint": true,
"onTypeFormatting": true,
"selectionRanges": true,
"semanticHighlighting": true,
"completion": true,
"codeLens": true,
"definition": true,
"workspaceSymbol": true,
"signatureHelp": true,
"typeHierarchy": true
},
"featuresConfiguration": {},
"addonSettings": {},
"rubyVersionManager": {
"identifier": "custom"
},
"customRubyCommand": "rbenv init - fish | source",
"formatter": "auto",
"linters": null,
"bundleGemfile": "",
"testTimeout": 30,
"branch": "",
"pullDiagnosticsOn": "both",
"useBundlerCompose": false,
"bypassTypechecker": false,
"rubyExecutablePath": "",
"indexing": {},
"erbSupport": true,
"featureFlags": {}
}
Reproduction steps
ruby-lsp auto-completes ruby blocks which is potentially a great feature, but the implementation is not quite there. Examples:
- Type
method do |. ruby-lsp autocompletes the argument pipes tomethod do ||, but the cursor is after the closing pipe, so attempting to finish typing e.g.|a|results inmethod do ||a||. You have to remember to arrow left before typing the argument. - Type
def method_name<enter>. ruby-lsp autocompletes the method structure with an empty line andend, but the cursor is afterendso you have to remember to arrow up before typing the method body. Same withdo ... endblocks.
This behavior IMO is unexpected because in other cases where VSCode autocompletes, the cursor is placed where you would expect. E.g. if you type " or ( you get "" or () but the cursor is between the two characters and you can immediately continue typing.
I really like the completion feature in concept, but since the cursor is placed in the wrong spot it slows me down to the point where disabling completion and typing the whole block myself is faster. Especially since completion isn't enabled in ERB files, so working on a Rails project I have to keep track of the context to type blocks successfully.
- Dominant language
- Ruby
- Stars
- 2k
- Forks
- 281
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/ruby-lsp
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug help-wanted pinned
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug pinned
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 68/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in Shopify/ruby-lsp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
TheOdinProject/curriculum#31417 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
glossarist/glossarist-ruby#238 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
palladius/rails8-app-on-gcp#145 ·