-
Notifications
You must be signed in to change notification settings - Fork 660
fix(rome_cli): correctly compute configuration #3176
Conversation
✅ Deploy Preview for rometools ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
1bd44ca
to
ce66ebd
Compare
} | ||
apply_format_settings_from_cli(&mut session, &mut workspace_settings)?; | ||
let configuration = apply_format_settings_from_cli(&mut session, configuration)?; | ||
session |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this change mean for concurrent usages of the deamon. Do the CLI argument change for all requests to the workspace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure want you mean. We only update the settings once (request), then each format_file
request (for example) reads those settings anytime they need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but what if multiple clients are connected to the same daemon
# client 1
rome format --indent-style="tab" --use-server
#client 2
rome format --indent-style="space" --use-server
And both commands run at the same time. Which configuration would be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both clients have two different instances of Workspace
, so their configuration won't mix up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good overall, can we just add an additional test that has both a configuration file and CLI arguments override to ensure the priority is handled correctly ?
Summary
Fixes #3175
We were incorrectly computing a
WorkspaceSettings
, while now we should change/create aConfiguration
struct instead and then update the settings of the workspace.This bug went undetected because we don't have tests that check that arguments passed via CLI are correctly applied.
Test Plan
I created two new tests, one that applies the generic configuration of the formatter and one that applies the configuration for the javascript language.