Skip to content

Address Zed Not Consider Empty String As 'Falsy' - #158

Draft
oisanjaya wants to merge 2 commits into
genericptr:trunkfrom
oisanjaya:texedit
Draft

Address Zed Not Consider Empty String As 'Falsy'#158
oisanjaya wants to merge 2 commits into
genericptr:trunkfrom
oisanjaya:texedit

Conversation

@oisanjaya

Copy link
Copy Markdown

Empty fields in JSON responses can be problematic, specifically Zed, they don't consider empty string as flasy. So if for example filterText is empty Zed don't fall back to "label" and doesn't show suggestion pop-up.
LSP allows omitting non-mandatory fields so removing those fields completely is better.

Also in this PR: use textEdit instead relying on client falling back to "label" for textDocument/completioni request

Rio Sanjaya added 2 commits July 26, 2026 16:26
LSP spec allows omitting non-mandatory fields, empty string can be problematic, Zed for example doesn't consider empty string as 'falsy'
@oisanjaya oisanjaya changed the title Texedit Address Zed Not Consider Empty String As 'Falsy' Jul 26, 2026
@genericptr

Copy link
Copy Markdown
Owner

This seems like a hack to me and I think it's released to the JSON streamer not supporting optional types so '' is passed instead. I.e, there's a default value which should be omitted but instead returns the default value for the Pascal type.

Is that what you mean?

@oisanjaya

Copy link
Copy Markdown
Author

Let's take insertText for example. In src/serverprotocol/PasLS.Completion.pas TCompletionItem.insertText property only populated when Identifier.IsProcNodeWithParams, otherwise it is in default value (empty string?). When this object serialized, it always included into response JSON. Since fInsertText is a string I don't think it can be set nil in order to omit this property during serialization, hence the hack "remove empty string" after serialization.
Problem with inclusion of insertText in Zed, they consider presence of insertText means empty string inserted into current line, clearing what user already typed. If this field absent, Zed correctly fall back to value of "label".

@genericptr

Copy link
Copy Markdown
Owner

See TOptional<T>. Does the spec say insertText is optional? if so maybe using TOptional will help because then it will be omitted from the JSON entirely.

We added that but only after using the wrong non-optional types is most places and just hoping the client will handle default values gracefully.

@oisanjaya

Copy link
Copy Markdown
Author

The spec defined as insertText?: string; with comment of When omitted, the label is used as the insert text for this item. I'll take your suggestion and try to work on various non-optional types, see how it is going.

Switching this PR to draft.

@oisanjaya
oisanjaya marked this pull request as draft July 27, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants