Skip to content
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

LS: Consider empty strings in workspace/configuration as None #6247

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

mkaput
Copy link
Member

@mkaput mkaput commented Aug 20, 2024

It occurs that the workspace/configuration
request returns Some("") for the cairo1.corelibPath
field even if it is not set anywhere.
This fact blocked any logic that happened in the find_unmanaged_core
function,
as it always assumed
that the user explicitly set the path in their config to "".
By nullifying empty configuration values, this change fixes
find_unmanaged_core.


Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.


This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

Reviewed all commit messages.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @Arcticae, @Draggu, @mkaput, and @piotmag769)


crates/cairo-lang-language-server/src/config.rs line 83 at r1 (raw file):

fn nullify_empty_str(value: &str) -> Option<&str> {
    (!value.is_empty()).then_some(value)
}

Suggestion:

            self.unmanaged_core_path = response
                .pop_front()
                .as_ref()
                .and_then(Value::as_str)
                .filter(|v|!v.is_empty())
                .map(Into::into);

            debug!("reloaded configuration: {self:#?}");
        }
    }
}

It occurs that the `workspace/configuration`
request returns `Some("")` for the `cairo1.corelibPath`
field even if it is not set anywhere.
This fact blocked any logic that happened in the ` find_unmanaged_core `
function,
as it always assumed
that the user explicitly set the path in their config to `""`.
By nullifying empty configuration values, this change fixes
`find_unmanaged_core`.

commit-id:c5cd2e07
@mkaput mkaput force-pushed the spr/main/c5cd2e07 branch from 773f54a to 94e0ee7 Compare August 21, 2024 07:27
Copy link
Member Author

@mkaput mkaput left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @Arcticae, @Draggu, @orizi, and @piotmag769)


crates/cairo-lang-language-server/src/config.rs line 83 at r1 (raw file):

fn nullify_empty_str(value: &str) -> Option<&str> {
    (!value.is_empty()).then_some(value)
}

🧠

Done

Copy link
Collaborator

@Draggu Draggu left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Arcticae, @orizi, and @piotmag769)

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae and @piotmag769)

Copy link
Collaborator

@piotmag769 piotmag769 left a comment

Choose a reason for hiding this comment

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

returns Some("") for the cairo1.corelibPath

Do you know why this happens? Isn't it an issue with our extension? Does it happen for other fields that are strings as well?

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae)

Copy link
Member Author

@mkaput mkaput left a comment

Choose a reason for hiding this comment

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

I tried to find a reason but couldn't conclude anything in reasonable time.

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae)

Copy link
Collaborator

@Arcticae Arcticae left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @mkaput)

@mkaput mkaput added this pull request to the merge queue Aug 22, 2024
Merged via the queue into main with commit 24d1268 Aug 22, 2024
87 checks passed
@mkaput mkaput deleted the spr/main/c5cd2e07 branch August 22, 2024 10:46
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.

5 participants