Skip to content

fix: use pointers for optional LSP settings [IDE-899] #811

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rrama
Copy link
Contributor

@rrama rrama commented Mar 25, 2025

Description

Previously we had no way to distinguish between the settings object being omitted and being set to "empty" value for the struct. As such we were ignoring settings objects that were set to the same as the "empty" struct value, as it would have broken / overridden the default LSP settings for clients that did not support the setting. With this change to using pointers, we can distinguish between a client not sending the settings object (because they don't support it yet) and a client sending the settings object but deliberately setting the values to be the same as the empty struct.

Checklist

  • Tests added and all succeed
  • Linted
  • README.md updated, if user-facing
  • License file updated, if new 3rd-party dependency is introduced
  • N/A

Previously we had no way to distinguish between the settings object being omitted and being set to "empty" value for the struct.
As such we were ignoring settings objects that were set to the same as the "empty" struct value, as it would have broken / overridden the default LSP settings for clients that did not support the setting.
With this change to using pointers, we can distinguish between a client not sending the settings object (because they don't support it yet) and a client sending the settings object but deliberately setting the values to be the same as the empty struct.
// Because in Go you can't do something like `takesPtr(&(returnsStruct()))`.
// So instead do `takesPtr(PtrOf(returnsStruct()))`.
func PtrOf[T any](value T) *T {
pointerToValue := new(T) // Heap may be safer than `&value`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love golang lol

@rrama rrama changed the title fix: WIP use pointers for optional LSP settings [IDE-899] fix: use pointers for optional LSP settings [IDE-899] Apr 8, 2025
@rrama rrama marked this pull request as ready for review April 8, 2025 10:34
@rrama rrama requested a review from a team as a code owner April 8, 2025 10:34
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