Skip to content

ReloadSettings only when we need to when saving a file#3688

Merged
dmaluka merged 1 commit intomicro-editor:masterfrom
Neko-Box-Coder:ReloadSettingsOnlyWhenNeeded
Mar 12, 2025
Merged

ReloadSettings only when we need to when saving a file#3688
dmaluka merged 1 commit intomicro-editor:masterfrom
Neko-Box-Coder:ReloadSettingsOnlyWhenNeeded

Conversation

@Neko-Box-Coder
Copy link
Contributor

@Neko-Box-Coder Neko-Box-Coder commented Mar 11, 2025

ReloadSettings only when we need to when saving a file instead of doing it every time when we save, which will also have the benefit of allowing old plugins to work.

Fixes #3687


ft := b.FileType()
b.UpdateRules()
if b.FileType() != ft || newFile {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if the file is not new but its path changes (i.e. after SaveAs)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

b.ReloadSettings(true)

ft := b.FileType()
b.UpdateRules()
Copy link
Collaborator

Choose a reason for hiding this comment

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

We only need to update rules exactly in the same cases when we need to reload settings (and thus would do that anyway as a part of ReloadSettings()), i.e. when path or filetype changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I think we only need to check if the path has changed. If the user is setting the filetype manually, it already triggers ReloadSettings.

@Neko-Box-Coder Neko-Box-Coder force-pushed the ReloadSettingsOnlyWhenNeeded branch 3 times, most recently from b68d509 to d02758e Compare March 11, 2025 02:34
@Neko-Box-Coder Neko-Box-Coder force-pushed the ReloadSettingsOnlyWhenNeeded branch from d02758e to 370239d Compare March 11, 2025 19:48
b.UpdateModTime()
b.ReloadSettings(true)

// need to update glob-based and filetype-based settings
Copy link
Collaborator

Choose a reason for hiding this comment

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

Inside the if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@Neko-Box-Coder Neko-Box-Coder force-pushed the ReloadSettingsOnlyWhenNeeded branch from 370239d to b3b765c Compare March 12, 2025 19:11
@dmaluka dmaluka merged commit 82b7003 into micro-editor:master Mar 12, 2025
6 checks passed
@Neko-Box-Coder Neko-Box-Coder deleted the ReloadSettingsOnlyWhenNeeded branch March 12, 2025 23:35
theredcmdcraft pushed a commit to theredcmdcraft/micro that referenced this pull request May 27, 2025
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.

regression: buffer-local options are reset when saving a file

3 participants