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
[BUG] Ibus-typing-booster automatically removes accents #420
Comments
What are your settings?
Especially I wonder whether you are using the |
Thanks, Mike. Yes, I am using the
|
Does the problem also happen, if you switch the autoselectcandidate option off? |
It appears that the problem only occurs with |
https://github.com/mike-fabian/ibus-typing-booster/blob/main/engine/hunspell_table.py#L2488 def _update_lookup_table_and_aux(self) -> None:
'''Update the lookup table and the auxiliary text'''
self._update_aux()
# auto select best candidate if the option
# self._auto_select_candidate is on:
self._is_candidate_auto_selected = False
if (self._lookup_table_is_invalid
and self.get_lookup_table().get_number_of_candidates()
and not self._lookup_table.cursor_visible):
if self._auto_select_candidate == 2:
# auto select: Yes, always
self._lookup_table.set_cursor_visible(True)
self._is_candidate_auto_selected = True
elif self._auto_select_candidate == 1:
# auto select: Yes, but only when extremely likely
first_candidate = ''
user_freq = 0
typed_string = ''
if self._candidates:
first_candidate = self._candidates[0][0]
user_freq = self._candidates[0][1]
typed_string = unicodedata.normalize(
'NFC',
self._transliterated_strings[self.get_current_imes()[0]])
spellcheck_single_dictionary = (
self.database.hunspell_obj.spellcheck_single_dictionary(
(self._p_phrase, self._pp_phrase, first_candidate)))
if (spellcheck_single_dictionary
and typed_string
and typed_string != first_candidate
and itb_util.remove_accents(first_candidate)
== itb_util.remove_accents(typed_string)
and user_freq > 0.2):
self._lookup_table.set_cursor_visible(True)
self._is_candidate_auto_selected = True
self._update_lookup_table()
self._lookup_table_is_invalid = False |
That is why I was very sceptical about the usefulness of that option. Automatically selecting a candidate can do bad things, it should only happen when it is really very certain that selecting that candidate is an advantage. In my last comment is the current code. In the
In your example, If that was only an accident, you could remove I am thinking about restricting the automatic selection even more though, probably like this:
That will avoid the problem you reported here and make autoselection happen more infrequently than now because it can only *add accents then if the typed word has no accents at all. Theoretically, I could make it a bit more complicated and allow some accents in the typed word and require only that the first candidate just adds more accents and does not remove or change any existing accents. I am not sure whether this more complicated check is worth doing. Maybe it is better to autoselect only when the typed word has no accents at all and the first candidate does nothing but add some accents. |
Thanks, Mike. I think that restricting auto-selection is a good idea. |
Test builds of 2.21.2 with the new behaviour for autoselecting (never remove accents) are here: https://copr.fedorainfracloud.org/coprs/mfabian/ibus-typing-booster/builds/ These builds also contain two new features which might be useful for you, see: and the following comments. In short, there is an option
now which disables Typing Booster in terminals like gnome-terminal, xfce4-terminal, konsole, xterm, rxvt, and urxvt completely without a way to turn it on there (no key binding can turn it on) And there is a more complicated advanced option which makes it possible to change any setting to a different value when a window matching a regular expression gets focus. This more complicated option has no GUI yet, I am still working on that. But it is already usable by setting the option on the command line. Using that option, it is possible to switch typing booster off when a terminal gets focus but keep the possibility to switch it on there again using a key binding. |
Thanks, Mike! The two new features you mention area great! |
New release: |
Thanks a lot for the very great advance this new version brings to users, Mike! The "Autosettings" are really amazing! I would suggest you to allow the users to edit the "Autosettings" already set up. For instance, to change |
Just out of interest, what are you using the autosettings for?
Surely you have seen that you can change the value and the regular expression but not the name of the setting. I thought about that and I might add the possibility to change the name of the setting later. The reasons why I didn’t do that yet are: When changing the name of the setting, almost always the value has to be changed as well. It absolutely has to change if the new setting needs a different type for the value, for example when it was an int before and then needs to be a bool or a str. If you change But the main reasons why I didn’t do it immediately have to do with the user interface: I don’t want to allow to edit the name of the setting as a free form text field like the regular expression where you can enter anything you like. The field for the values already does some very basic checks and refuses to let you enter some invalid stuff. For example if you try to type anything else but "True", "true", "False", or "false" into a value field expecting a bool, it does not accept that and sets the field to empty again, shows the hint When allowing to edit the field for the name of the setting by typing into that field, I surely should check for input which is not an allowed setting and refuse. But making the user type the full setting is inconvenient anyway, when adding a new setting with the That is pretty easy to do, but then I thought about where that popup should point to. When clicking the But when double clicking on an already existing name of a setting, having the popover point to that In Gtk3 (ibus-typing-booster is currently using Gtk3) I can set such a popover relative to anything I like. For example in emoji-picker I do this when you right click on an emoji: The popover points to the emoji you right clicked on. In Gtk3, this thing the popover points to can be anything one likes: https://docs.gtk.org/gtk3/method.Popover.set_relative_to.html I feel it would be natural to make the popover point to the setting one has just double clicked to edit it instead of making it point to the In Gtk4, the popover does not have the https://docs.gtk.org/gtk4/migrating-3to4.html
So in order to make it possible that the popover points to the name of the setting which was just double clicked, I probably would need to put GtkMenuButton into the first column of the treeview listing the autosettings. Currently, these are just strings. Eventually I want to port ibus-typing-booster to Gtk4. Therefore, I don’t want to add any more stuff which is easy to do in Gtk3 but makes porting to Gtk4 more difficult. If I want to do this now, I should probably try in Gtk3 already whether I can put GtkMenuButtons into the first column instead of strings. I then wondered how the look and feel would change if I do that. Probably the first column would look a little bit different then. Which might actually be a good thing. And it might offer some new possibilities like showing a tooltip on each of these menu buttons explaining in more detail what this setting is about and what to enter as the value. A tooltip for So when I thought about this and kept the future migration to Gtk4 in mind, I thought this is going to be quite complicated, I should think more about it before doing this. A lot of extra work for very little effect. And as I will be going on vacation soon, I wanted to finish the work on the autosettings GUI and make a release before going on vacation. If you have more ideas about how this should work and how it should look like, please share your ideas. I will think about it and maybe improve the autosettings GUI after my vacation. |
Thanks, Mike, for your answer! I find autosetting fantastic because now I can have ibus-typing-booster automatically switching on where I want it switched on: gedit, WhatsApp, thunderbird, etc. Until now, I had to manually switch on and off ibus-typing-booster. Regarding the possibility of editing the first setting of autosettings, I agree with you: Too much work for such a small benefit -- I did not imagine the whole complexity you describe in your answer. Perhaps, the best is to leave it as it is. I have an idea: To make the selection of the focused window easier. For instance, I have not been able to find a way to address Google Chrome. I have tried:
I do not know whether it is possible to have a search input box where one would insert |
If that does not work for you, my guess is you are using Gnome Wayland and did not set the environment variable to enable the accessibility interface to be used by google-chrome and firefox:
See the end of the chapter about the autosettings in the online documentation: https://mike-fabian.github.io/ibus-typing-booster/docs/user/#2_2_7 |
Thanks, Mike, for your reply. I guess I am not using Gnome Wayland, but the X Window System. Moreover, I can address Firefox with the autosettings, but not Chrome. |
All these 3 should work (and they work for me actually). You do not need to escape the As all these 3 should work, but apparently didn’t work for you, my guess in the last comment was that you are using Gnome Wayland and did not set
which is necessary to make this work for google-chrome. Even though Using just At the minimum, I would recommend to use:
Do you know regular expressions? The As the format for the client id is
using Just using But even
So to make it even more reliable, better don’t just guess and use vague matches using And add the toolkit in front to make it even less likely for the regular expression to accidentally match in some window title, i.e. better use
This still could theoretically match by accident in the window title, so to make it perfectly safe, require that the match starts at the beginning by adding a So this would be the most reliable regular expression to match only google-chrome and nothing else:
|
This is weird because on Xorg it should just work without setting any environment variables. |
I have not set |
Did you check what happens when you set the debug level in the typing-booster settings to >=1 and type into google-chrome using Typing Booster until you see a candidate list? You should see a debug text on top of the candidate list starting with the window emoji 🪟, after that emoji you should see the client id which google-chrome has and which the regular expression must match. |
By following your instructions, Mike, I found that, in my case, we need to use:
The word And yes, I do know regex. |
Oh, surprising! I installed google-chrome by having this repo:
and then
|
One could use |
That one has to do this with regular expression makes the "autosettings" really a feature only usable by quite advanced users. But I see no other way to do it, I think the flexibility of the regular expressions is needed to allow the user to specify exactly which windows should match. |
Thanks, Mike. Yes, I think that its very reasonable to intend the autosettings to advanced users. And, therefore, regular expressions are the best option. |
Yes, then it cannot work, unfortunately. I have no idea at the moment how to get any more information than
|
Thanks, Mike, anyway. |
This extension does the trick for Firefox: https://addons.mozilla.org/en-US/firefox/addon/tab-retitle/ Using that, I can automatically rename all tabs for the domain chat.openai.com to Maybe there is a similar extension for Google Chrome. |
Same extension for Google Chrome: |
Thanks a lot, Mike! That works fine! |
I have some ideas about how to improve figuring out the window ids. Currently the best way is to set the debug level to >= 1 and type in the window you are interested in and see what the debug string on top of the candidate list shows. Or grep through the debug.log. But ibus-typing-booster sees all these strings while you click around. It could collect them. To communicate these to the setup tool, one would need to store them somewhere, where the setup tool also has access, one could for example store it in a special gsettings key. As the window titles may contain private information, one could store only the In the "Autosettings" tab of the setup tool, ibus-typing-booster could then also show a searchable list of window ids which it already has seen before. If one has been using typing-booster for a while, most of the windows a user typically uses should already be there and if it is searchable, searching for "chrome" in your case would have easily found Such a searchable list could be displayed below the list of autosettings. Or, maybe better, such a searchable list could popup when one starts to edit an empty regexp field and one could search and choose one of these offered or choose none and start from scratch. And then refine the regexp for the chosen one by adding window title stuff for example. A friend suggested, that one could ask the user to click a window to get a window id for that window filled into the regexp field. Like when you add a key binding, you don't have to type So the setup tool could ask: Now click the window you want! Then typing-booster could get that window id and communicate it via gsettings back to the setup tool and the setup tool could then fill it in and let the user do more editing to refine it. This is quite complicated though. And there are many problems in the details. Quite often, clicking a window does not yet give that information immediatelyl For example, when clicking a firefox tab which shows the language learning site www.duolingo.com, that duolingo page might be in a state where no input is possible at the moment and then typing-booster may not see a focus_in event. Or sometimes it sees focus_in events which have So the idea of "Click the window you want!" and then fill in the regexp has a lot of problems in the details, I am not sure whether it is possible to make that work reliably. But showing a searchable list of already known window ids when starting to edit an empty regexp field might be very helpful. But as I am going on vacation soon, I just write down this ideas for improvement, I might work on this later. |
Thanks, Mike, for the ideas that you advance: They are all very good! And yes, I have noticed that, from time to time, ibus-typing-booster does not turn on in the window selected: One needs to leave the window and come again. Perhaps, as you say, the window is busy with something else. |
It is possible that in that case when it does not turn on, that the window id is So maybe if you change the regexp to With the Although turning it on when input is not possible anyway is not really useful, it may look more natural that it switches to the 🚀 icon instead of the 🐌 more reliably on entering the window, even if no input is possible. Not sure whether this helps, but it might, would be interesting to try it out whether this works better for you. |
Thanks, Mike. By using
it seems that it works better, in the sense that I have not noticed any delay, up to now, in ibus-typing-booster switching on in the selected windows. If the problem recurs, I will report that here. |
Great that you tested that! One can never see these client ids starting with So I should think about how to make this a bit easier to figure out. |
It has worked just fine, Mike! The autosettings is really a very great improvement of ibus-typing-booster: It avoids the constant manual switching on and off. |
Please, Mike, see the attached video, which shows the problem on
gedit
. Thanks!Peek.2023-02-10.16-02.mp4
The text was updated successfully, but these errors were encountered: