-
Notifications
You must be signed in to change notification settings - Fork 172
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
Code completion for blocks is unhelpful due to cursor placement #2971
Labels
bug
Something isn't working
Comments
thedanbob
added
bug
Something isn't working
vscode
This pull request should be included in the VS Code extension's release notes
labels
Dec 11, 2024
I've experienced this as well. Here are the RPC messages. (Cursor position is denoted by DATA.readlines do |█ Results in: DATA.readlines do ||█ // Send:
{
"jsonrpc": "2.0",
"method": "textDocument/didChange",
"params": {
"textDocument": {
"uri": "file:///Users/thomascountz/Code/pipe-character-test.rb",
"version": 179
},
"contentChanges": [
{
"range": {
"start": {
"line": 5,
"character": 18
},
"end": {
"line": 5,
"character": 18
}
},
"text": "|"
}
]
}
}
// Send:
{
"jsonrpc": "2.0",
"id": 465,
"method": "textDocument/onTypeFormatting",
"params": {
"textDocument": {
"uri": "file:///Users/thomascountz/Code/pipe-character-test.rb"
},
"position": {
"line": 5,
"character": 19
},
"ch": "|",
"options": {
"tabSize": 2,
"insertSpaces": true,
"trimTrailingWhitespace": true,
"insertFinalNewline": true,
"trimFinalNewlines": true
}
}
}
// Receive:
{
"id": 465,
"result": [
{
"range": {
"start": {
"line": 5,
"character": 19
},
"end": {
"line": 5,
"character": 19
}
},
"newText": "|"
}
],
"jsonrpc": "2.0"
}
// Send:
{
"jsonrpc": "2.0",
"method": "textDocument/didChange",
"params": {
"textDocument": {
"uri": "file:///Users/thomascountz/Code/pipe-character-test.rb",
"version": 180
},
"contentChanges": [
{
"range": {
"start": {
"line": 5,
"character": 19
},
"end": {
"line": 5,
"character": 19
}
},
"text": "|"
}
]
}
}
// Send:
{
"jsonrpc": "2.0",
"id": 466,
"method": "textDocument/documentHighlight",
"params": {
"textDocument": {
"uri": "file:///Users/thomascountz/Code/pipe-character-test.rb"
},
"position": {
"line": 5,
"character": 20
}
}
}
// Receive:
{
"id": 466,
"result": [],
"jsonrpc": "2.0"
}
// Send:
{
"jsonrpc": "2.0",
"id": 467,
"method": "textDocument/codeAction",
"params": {
"textDocument": {
"uri": "file:///Users/thomascountz/Code/pipe-character-test.rb"
},
"range": {
"start": {
"line": 5,
"character": 20
},
"end": {
"line": 5,
"character": 20
}
},
"context": {
"diagnostics": [],
"only": [
"",
"quickfix",
"refactor",
"refactor.extract",
"source"
]
}
}
}
// Receive:
{
"id": 467,
"result": [],
"jsonrpc": "2.0"
}
// Send:
{
"jsonrpc": "2.0",
"method": "workspace/didChangeWatchedFiles",
"params": {
"changes": [
{
"uri": "file:///Users/thomascountz/Code/pipe-character-test.rb",
"type": 2
}
]
}
} |
vinistock
removed
the
vscode
This pull request should be included in the VS Code extension's release notes
label
Dec 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 Version
3.3.6
Ruby Version Manager
custom
Installed Extensions
Click to expand
Ruby LSP Settings
Click to expand
Workspace
User
Reproduction steps
ruby-lsp auto-completes ruby blocks which is potentially a great feature, but the implementation is not quite there. Examples:
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.def method_name<enter>
. ruby-lsp autocompletes the method structure with an empty line andend
, but the cursor is afterend
so you have to remember to arrow up before typing the method body. Same withdo ... end
blocks.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.
The text was updated successfully, but these errors were encountered: