-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[preferences] fix indentation when updating preferences through the tree #6736
Conversation
57917f7
to
d681787
Compare
packages/preferences/src/browser/abstract-resource-preference-provider.ts
Outdated
Show resolved
Hide resolved
packages/preferences/src/browser/abstract-resource-preference-provider.ts
Outdated
Show resolved
Hide resolved
Test the format on Ubuntu 16.04 and Chrome: works fine |
3009c48
to
a3f3115
Compare
@akosyakov I noticed a potential issue with the preferences for languages. During testing, I updated the global preference I had to do the following as a workaround: "[json]": {
"editor.insertSpaces": false
} Also, not sure if we should use |
79e336d
to
575670d
Compare
@vince-fugnitto I think |
packages/preferences/src/browser/abstract-resource-preference-provider.ts
Show resolved
Hide resolved
packages/preferences/src/browser/abstract-resource-preference-provider.ts
Outdated
Show resolved
Hide resolved
575670d
to
9ecb9d3
Compare
packages/preferences/src/browser/abstract-resource-preference-provider.ts
Outdated
Show resolved
Hide resolved
9ecb9d3
to
597af1b
Compare
packages/preferences/src/browser/abstract-resource-preference-provider.ts
Outdated
Show resolved
Hide resolved
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.
code-wise it looks good to me
Fixes #5052 - fixes the indentation when updating/setting a preference using the `preferences-tree` widget. - the current implementation had a hardcoded value of `tabSize`=3 and `insertSpaces`=true which meant that if the `settings.json` file had different formatting, it would insert incorrectly. - added a new method `getFormattingOptions` which gets the preference options for tabSize and indentation type. - fixed typings from the `preference-service`. If a default value is provided, the preference should return that value if the preference initially returns `undefined`. Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
597af1b
to
488a5b1
Compare
@lmcbout if you get a chance, can you please re-test the pull request? |
Tested with @vince-fugnitto not perfect, but OK |
@lmcbout I completely understand, the pull request becomes best effort when the settings document is not properly formatted or is formatted inconsistently (different When the document is properly formatted, inserting preferences from the Perhaps we can improve the pull request further in the future, but I am unsure what an appropriate strategy would be when working with un-formatted documents. |
What it does
Fixes #5052
Fixes the inconsistent formatting when attempting to update/set preferences using the
preferences-tree
widget. Since the formatting options passed tojsoncparser
were hardcoded, the formatting would be inconsistent with whichever formatting the editor currently has:theia/packages/preferences/src/browser/abstract-resource-preference-provider.ts
Line 107 in 928e1e0
In order to fix the issue, the following method
detectIndentation
was implemented which attempts to determine thetabSize
andindentType
(insertSpaces
) directly from theTextEditorDocument
of thesettings.json
file in question. This is done in order to get a more accurate representation of the actual formatting present in the file.The following is the before and after when adding a new preference
terminal.enableCopy
through thepreferences-tree
:tabSize
=8)tabSize
=8)How to test
tabSize
using the statusbar and format the document accordingly (repeat step 1)indentType
(spaces or tabs) using the statusbar, format the document accordingly (repeat step 1)user
andworkspace
filesReview checklist
Reminder for reviewers
Signed-off-by: vince-fugnitto vincent.fugnitto@ericsson.com