-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
buffer: Fix ReloadSettings(true)
for volatile filetype
#3662
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3cf4692
to
93c11d6
Compare
dmaluka
approved these changes
Feb 13, 2025
niten94
reviewed
Feb 14, 2025
This comment was marked as resolved.
This comment was marked as resolved.
93c11d6
to
56659e3
Compare
niten94
reviewed
Feb 15, 2025
31fe12c
to
bcd97ec
Compare
niten94
approved these changes
Feb 15, 2025
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.
I've now read the code a lot that I understand it more and didn't test, but it seems to be fine other than some changes that are being done in an unrelated commit.
dmaluka
reviewed
Feb 16, 2025
885aae1
to
597d606
Compare
dmaluka
reviewed
Feb 16, 2025
dmaluka
reviewed
Feb 16, 2025
We shall not overwrite a volatile set `filetype` provided as argument for micro: `micro -filetype shell foo`
597d606
to
3e81d91
Compare
dmaluka
reviewed
Feb 18, 2025
3e81d91
to
882668b
Compare
dmaluka
reviewed
Feb 19, 2025
* `UpdatePathGlobLocals()` * to apply the settings provided within e.g. "/etc/*": {} * `UpdateFileTypeLocals()` * to apply the settings provided within e.g. "ft:shell": {} We don't need to call `InitLocalSettings()` twice any longer.
This shall prevent unpredictable results caused by such a user configuration: ``` "ft:go" { "filetype": "c" } ```
Like in NewBuffer(), we need to update glob-based local settings before updating the filetype, since the filetype itself may be among those glob-based local settings.
In `ReloadSettings()` the `filetype` can change upon globbed path given by the `settings.json` or by identifying a different `filetype` based on the file name given or pattern present inside the file. To prevent further recursion caused by checking the `filetype` again, its processing stops here and isn't considered in `DoSetOptionNative()` once again where the callbacks are usually triggered.
Setting options directly in (h.)Buf.Settings without calling SetOption() or SetOptionNative() is generally not the best idea, since it may not trigger the needed side effects. In particular, after zyedidia#3343, directly setting `diffgutter` and `ruler` causes them not being tracked as locally overridden per buffer, so if we run the `reload` command, it unexpectedly replaces them with the default ones.
882668b
to
ddc6051
Compare
dmaluka
approved these changes
Feb 20, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As found out by @niten94 we didn't perform the callbacks in case we reload the
filetype
.Fixes #3659