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

Keybinding for ["normal_mode", ":write"] doesn't remove file-modification-indicator #6513

Closed
rdscott-vrsk opened this issue Mar 31, 2023 · 5 comments
Labels
C-bug Category: This is a bug

Comments

@rdscott-vrsk
Copy link

rdscott-vrsk commented Mar 31, 2023

Summary

A keybinding like

[keys.insert]
k = { j = ["normal_mode", ":write"] }

Will exit insert mode and write the file, but the file-modification-indicator will remain in the bufferline and statusline (if configured) as if the file were not saved.

This appears to be specific to having the :write be a second command in a list, or when going from insert mode to normal mode. Key bindings that save when triggered in normal mode work as expected.

Reproduction Steps

No response

Helix log

Log shows stuff like this:

2023-03-31T11:08:13.875 helix_view::document [DEBUG] id 9 modified - last saved: 0, current: 0
2023-03-31T11:08:13.875 helix_view::document [DEBUG] id 10 modified - last saved: 10, current: 10
2023-03-31T11:08:13.875 helix_view::document [DEBUG] id 7 modified - last saved: 0, current: 4

Platform

macOS

Terminal Emulator

wezterm 20230326-111934-3666303c

Helix Version

helix 23.03 (3cf0372)

@rdscott-vrsk rdscott-vrsk added the C-bug Category: This is a bug label Mar 31, 2023
@Xalfer
Copy link
Contributor

Xalfer commented May 24, 2023

I've looked into this and it appears that right after writing it creates a new revision because it is still in insert mode. This new revision has a different id than the id of the last changed revision, which is why the file-modification-indicator appears.

One way I managed to fix this issue is by adding doc.append_changes_to_history(view) in helix-term::commands::typed::write_impl and helix-term::commands::typed::write_all_impl. But this feels like a hack so I want to find a better solution.

@connortsui20
Copy link
Contributor

I'd like to just mention here since it is not brought up anywhere else that for some file types (like .rs), this is not a problem, likely because of auto-formatting with rust-analyzer. Since #7226 is not done yet, maybe this could be helpful in figuring out a slick way to fix this? I can't really tell if the general solution there actually works or not

@Joe-Zer0
Copy link
Contributor

Joe-Zer0 commented Oct 13, 2023

I am having the same issue. When pressing C-s while in insert mode, the file does save. But the file modification indicator remains and I must use :q! to quit.

[keys.insert]
C-s = ["normal_mode", ":write"]

Windows Terminal - 1.18.2822.0
PowerShell Core - 7.3.8
Helix - 9f6e9a1 - 2023-10-13

@Joe-Zer0
Copy link
Contributor

I updated my keymap to this as a temporary work around.

[keys.insert]
C-s = ["normal_mode", "commit_undo_checkpoint", ":write"]

reference - #3501 (comment)

@pascalkuthe
Copy link
Member

Duplicate of #3501

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants