You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Return key does not trigger Language Server onTypeFormatting request (no end completion) #72
I looked to see how the Lua extension handles this, since it also has end, but it's a different approach. It's based on textDocument/publishDiagnostics. So after you type if true then, a suggested fix pops up to add the end, and hitting return selects that.
This seems to be a Zed issue. According to Claude Code's codebase inspection, Zed doesn't send document/onTypeFormatting requests when pressing enter, not only in Ruby files.
AI summary
⏺ Based on my analysis of the Zed codebase, no, Zed does NOT send document/onTypeFormatting LSP requests when pressing Enter.
Here's what I found:
Key Evidence
1. Separate code paths:
- Regular character input goes through handle_input() (editor.rs:4037) which calls trigger_on_type_formatting() (editor.rs:4380)
- Pressing Enter uses a dedicated newline() function (editor.rs:4468) that does NOT call trigger_on_type_formatting()
2. The newline function: The newline() function handles its own logic for inserting newlines, comment continuation, and indentation, but never triggers on-type formatting.
3. Test evidence: The test test_on_type_formatting_is_applied_after_autoindent (editor_tests.rs:17073) confirms this:
- It simulates pressing Enter at line 17094
- Then simulates pressing "." at line 17114
- Only the "." character triggers the on-type formatting request, not the newline
4. Implementation details: While trigger_on_type_formatting() only accepts single-character input (editor.rs:5398), which "\n" would satisfy, the newline action bypasses this
code path entirely.
So even if a language server declares "\n" as a trigger character in its documentOnTypeFormattingProvider, Zed won't send the request because Enter key presses use a separate
implementation that doesn't participate in on-type formatting.
This was fixed in zed-industries/zed#44882. The cursor positioning is broken after end is inserted – just like with | as shown in #38 – but at least document/onTypeFormatting is now being sent on enter.
BTW, it seems that Lua extension actually has a snippet for then .. end, which triggers end being auto-inserted after typing if true then + enter. It does have diagnostics, but I don't get offered to fix it while typing. This approach has limitations, e.g. end doesn't get auto-inserted after typing function foo() + enter.
Activity
andyw8 commentedon Apr 23, 2025
I looked to see how the Lua extension handles this, since it also has
end, but it's a different approach. It's based ontextDocument/publishDiagnostics. So after you typeif true then, a suggested fix pops up to add theend, and hitting return selects that.andyw8 commentedon Apr 23, 2025
This likely relates to
more_trigger_character:https://github.com/Shopify/ruby-lsp/blob/f3ff6a36afbc7134d640c8e6be54c7c8f63f0aaf/lib/ruby_lsp/requests/on_type_formatting.rb#L15
Mentioned here (
moreTriggerCharacter) in the spec:https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_onTypeFormatting
janko commentedon Nov 19, 2025
This seems to be a Zed issue. According to Claude Code's codebase inspection, Zed doesn't send
document/onTypeFormattingrequests when pressing enter, not only in Ruby files.AI summary
janko commentedon Nov 19, 2025
I had opened zed-industries/zed#12383, but if it's indeed not specific to Ruby, I think it should be opened as a generic issue.
janko commentedon Dec 16, 2025
This was fixed in zed-industries/zed#44882. The cursor positioning is broken after
endis inserted – just like with|as shown in #38 – but at leastdocument/onTypeFormattingis now being sent on enter.andyw8 commentedon Dec 20, 2025
Nice. Hopefully #38 can be solved soon.
janko commentedon Dec 28, 2025
BTW, it seems that Lua extension actually has a snippet for
then .. end, which triggersendbeing auto-inserted after typingif true then+ enter. It does have diagnostics, but I don't get offered to fix it while typing. This approach has limitations, e.g.enddoesn't get auto-inserted after typingfunction foo()+ enter.