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

Add a configuration parameter for trimming whitespace on save #60

Merged
merged 1 commit into from
Jul 23, 2022

Conversation

iainh
Copy link
Contributor

@iainh iainh commented Jul 22, 2022

Prior to this change trailing whitespace is always remove when a file is saved. This can be expensive for very large files and in some cases may not be wanted by the user. Add a new configuration parameter trim_trailing_whitespace_on_save to allow the user to change the behaviour globally.

This change also moves the call to strip_trailing_whitespace() before the call to File::create reducing the amount of time that between when the file has been truncated and when the contents are written back.

Prior to this change trailing whitespace is always remove when a file is saved. This can be expensive for very large files and in some cases may not be wanted by the user. Add a new configuration parameter `trim_trailing_whitespace_on_save` to allow the user to change the behaviour globally.
@kevinmatthes
Copy link
Contributor

Thank you for this Pull Request!

Just one question: did you test whether the assertion in zee/src/syntax/parse.rs, line 163, is still triggered when entering text after cropping whitespaces on saving?

Copy link
Collaborator

@mcobzarenco mcobzarenco left a comment

Choose a reason for hiding this comment

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

@iainh Looks good, thanks for the changes!

I imagine eventually we want to be able to run mode-specific linters on save, so this option would have to be mode specific. But that's for the future.

This change also moves the call to strip_trailing_whitespace() before the call to File::create reducing the amount of time that between when the file has been truncated and when the contents are written back.

The one downside of this is that we trim the whitespace, even if we may not be able to create the file -- say for permissions reasons, io error etc.

@kevinmatthes On

Just one question: did you test whether the assertion in zee/src/syntax/parse.rs, line 163, is still triggered when entering text after cropping whitespaces on saving?

I think that should be fine. Btw, looking into the colour panic today -- sorry for the delay.

@mcobzarenco mcobzarenco merged commit 179f959 into zee-editor:master Jul 23, 2022
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.

None yet

3 participants