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

fix: Use vim_dialog_yesno for the "file changed since reading" message #29310

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

murtaza64
Copy link

@murtaza64 murtaza64 commented Jun 13, 2024

In order to allow more flexibility in how UI plugins like Noice handle this specific prompt, switch from using ask_yesno to vim_dialog_yesno, which sends a msg_send.confirm event which can be handled by vim.ui_attach. This also brings it in line with other user prompts such as the swapfile dialog.

Before:
image

After:
image

With Noice:
image

Questions/feedback requested:

  • I felt like combining the existing two messages together creates a better UX for this flow, but happy to leave it as is if that's preferred
  • Even without combining the two strings onto one line, I probably would still need to update localization (at least to add the question mark that ask_yesno used to add). I'm happy to take a crack at that, but I'm having trouble testing it. Doing VIMRUNTIME=runtime ./build/bin/nvim --clean and then setting :lang es_ES doesn't seem to use Spanish strings :/

@murtaza64 murtaza64 marked this pull request as ready for review June 13, 2024 04:46
@murtaza64
Copy link
Author

This is my first PR in neovim core so I'm not sure if I should assign anyone or who I could reach out to for feedback, but feedback is very much appreciated!

@murtaza64
Copy link
Author

@tjdevries you're the only core maintainer I know the name of so tagging you for feedback and/or to point me in the right direction. This is my first PR in neovim :)

if (vim_dialog_yesno(VIM_WARNING,
NULL,
_(
"WARNING: The file has been changed since reading it. Do you really want to write to it?"),
Copy link
Member

Choose a reason for hiding this comment

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

Just out of curiosity, any special reason to change the message slightly (e.g. dropping the exclamation marks)?

Copy link
Author

Choose a reason for hiding this comment

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

No special reason, but I always found the three exclamation marks a bit over the top in addition to the all caps WARNING. Don't feel too strongly about it though.

msgstr "¿Desea realmente escribir al archivo?"
#: ../bufwrite.c:362
msgid "WARNING: The file has been changed since reading it. Do you really want to write to it?"
msgstr "ADVERTENCIA: El archivo ha cambiado desde que se leyó. ¿Desea realmente escribir en él?"
Copy link
Member

Choose a reason for hiding this comment

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

What about other locale files other than Spanish?

Copy link
Author

@murtaza64 murtaza64 Jun 14, 2024

Choose a reason for hiding this comment

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

I was having trouble testing this one, :lang es_ES on my dirty build doesn't seem to do anything. Do I have to put the localization files somewhere for it to pick them up?

{9: reading it!!!} |
{6:Do you really want to write to it (y/n)?}|
^ |
{6:WARNING: The file has been changed since}|
Copy link
Member

@wookayin wookayin Jun 14, 2024

Choose a reason for hiding this comment

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

It'd be just a personal taste, but I would actually prefer shouting, intimidating warning messages that are put in red (WarningMsg) or more discernible than simple MoreMsg highlights.

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, I guess we could still print the first line in WARNING colors like it did before, but the main idea behind this change is to allow ui_attach to handle this prompt gracefully, and splitting the message into two makes it harder to do that

Copy link
Author

Choose a reason for hiding this comment

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

I could also look into the implementation of do_dialog to see if we can use different highlights for the message

{6:Press ENTER or type command to continue}^ |
]])

feed('<cr>')
Copy link
Member

Choose a reason for hiding this comment

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

Q: why removing those tests?

Copy link
Author

Choose a reason for hiding this comment

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

With vim_dialog_yesno, after pressing 'n', the "Press ENTER" line doesn't appear

@wookayin wookayin added the messages UI messages, log messages label Jun 14, 2024
@glepnir
Copy link
Member

glepnir commented Jun 14, 2024

this part is common to vim. I suggest you submit it to vim first.

@murtaza64
Copy link
Author

this part is common to vim. I suggest you submit it to vim first.

I could give it a shot, but I suspect they won't see the value in this change since the main reason is to make it play nicely with ui_attach which is neovim only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
messages UI messages, log messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants