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

Report error when setting a wrong guifont value #2089

Merged
merged 8 commits into from Oct 31, 2023

Conversation

Tmpod
Copy link
Contributor

@Tmpod Tmpod commented Oct 23, 2023

What kind of change does this PR introduce?

It addresses #2077 by fist implementing a new parallel UiCommand, ShowError { message: String } which gets translated to neovim's echomsg, and then using it in tandem with log::error! in CachingShaper::update_font (when self.font_loader.get_or_load fails).

Did this PR introduce a breaking change?

  • Yes
    • Invalid guifont values will now error out instead of silently being accepted. To pick no hinting or aliased edging, you should now use #h-none and #e-alias, respectively.
      • Actually, just checked the docs, and they already specified those options, even though the code didn't check for them specifically, they were just being handled on the wildcard match. Still this is a breaking change because of the new errors.

Closes #2077

@Tmpod
Copy link
Contributor Author

Tmpod commented Oct 23, 2023

At the moment, this is not producing any message, though the log is going through just fine.

I'm not familiar with Neovim's API, so perhaps I'm not using echomsg right?

PS: I'm aware of the extra : there, my bad, will remove in later commit.

src/bridge/mod.rs Outdated Show resolved Hide resolved
Also remove the extra column on the error message.
@Tmpod
Copy link
Contributor Author

Tmpod commented Oct 24, 2023

Alright, this is now working. I have two questions regarding the code though (sorry, first contribution!)

  1. Since show_error_message is just a forward call to Neovim::err_writeln, is it really worth having? Perhaps it would just be best to use that neovim API call directly in the command match arm.
  2. Should I write a test for this, and if so, where?

Thank you!

@fredizzimo
Copy link
Member

@Tmpod.

  1. We use the nvim api directly elsewhere in the file, so I think removing the function makes sense. It's clear what writeline does.
  2. I think tests are quite hard for this, since they would rely on the fonts installed on the system or require some mocking. Additionally, the actual functionality is quite trivial, so I don't think we need any tests.

The only thing left to do would be to also verify the fallback fonts. But if you are unsure how to do that, we can leave it for later in another PR. Basically, you need to try loading all of the fonts in the guifont list.

BTW, I'm also on Discord so if you have further questions, you can ask there too.

@Tmpod
Copy link
Contributor Author

Tmpod commented Oct 24, 2023 via email

Also do a simple comma-separated join of font names
instead of relying on `Debug` formatting.
This new macro accepts `format!`-like arguments and does
both an `error!` log and a `ShowError` neovim command.
Fix `FontOptions::allow_float_size` not being set for
float width values.

Fix failed assert message formatting arguments being in
incorrect order, or just completely incorrect.
@Tmpod Tmpod force-pushed the task/2077/warn-wrong-guifont branch from 809379d to 8f5a56b Compare October 25, 2023 00:37
@Tmpod Tmpod marked this pull request as ready for review October 25, 2023 00:38
@fredizzimo fredizzimo merged commit c041cc6 into neovide:main Oct 31, 2023
2 checks passed
@fredizzimo
Copy link
Member

Thank you!

@Tmpod
Copy link
Contributor Author

Tmpod commented Oct 31, 2023 via email

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

Successfully merging this pull request may close these issues.

Setting the wrong guifont should report errors
2 participants