Skip to content

Make sure that user symbols without a replacement are properly ignored#8932

Merged
michaelDCurran merged 1 commit into
nvaccess:betafrom
BabbageCom:i8931
Nov 29, 2018
Merged

Make sure that user symbols without a replacement are properly ignored#8932
michaelDCurran merged 1 commit into
nvaccess:betafrom
BabbageCom:i8931

Conversation

@LeonarddeR

@LeonarddeR LeonarddeR commented Nov 10, 2018

Copy link
Copy Markdown
Collaborator

Link to issue number:

Related to #8931. It does not yet fix it, but provides a fix for the error involved.

Summary of the issue:

When adding a symbol without a replacement to the user symbols, an error is raised when this symbol is encountered in text. This is because the symbol is properly removed from the list of symbols, but it is still included in the regex that is created to extract symbols from text in order to replace them.

Description of how this pull request fixes the issue:

Remove the symbol identifier for a symbol without a replacement from the list of characters before building the regular expression.

Testing performed:

Tested the steps to reproduce as explained in #8931.

Known issues with pull request:

It does not fix #8931, this will require additional work and is a bit lower in priority.

Change log entry:

  • Bug fixes
    • NVDA no longer fails reading text in case a defined user symbol is encountered for which a replacement pattern isn't specified.

@nvdaes

nvdaes commented Nov 10, 2018

Copy link
Copy Markdown
Collaborator

Thanks for this, it fixes the issue, but imo it produces an inconsistency and is not exactly the expected behavior:

Expected behavior:
The symbol should be read according with the chosen parameters, even when other > emojis are excluded.

  1. If a replacement is not included for the emoji and other values are changed, and then emojis are excluded, the symbol is not read regardless of the symbols level, so the other parameters are aplied when emojis are included.
  2. If the replacement has been changed, then it would be read even when emojis are excluded. and the parameters are applied too.

This is my opinion. Your feedback is appreciated.

Thanks

@LeonarddeR

LeonarddeR commented Nov 10, 2018

Copy link
Copy Markdown
Collaborator Author

Thanks for this, it fixes the issue, but imo it produces an inconsistency and is not exactly the expected behavior:

Expected behavior:
The symbol should be read according with the chosen parameters, even when other > emojis are excluded.

1. If a replacement is not included for the emoji and other values are changed, and then emojis are excluded, the symbol is not read regardless of the symbols level, so the other parameters are applied when emojis are included.

This is true. However, it is not very trivial to fix this. IN short, it probably requires treating emoji dictionaries as separate dictionaries, and that requires a lot of work.

2. If the replacement has been changed, then it would be read even when emojis are excluded. and the parameters are applied too.

I agree that this is inconsistent. The erroneous part of this issue is fixed though. Let's leave #8931 open for now.

@nvdaes

nvdaes commented Nov 10, 2018

Copy link
Copy Markdown
Collaborator

Many thanks. I think it's a good idea treat emojis in separate dictionaries, or in a general way, profile dictionaries for symbols. I could try to collaborate if needed, but I don't like to make things difficult to experiment devs like you, since sometimes devs may find easier to work yourself than review and discuss with other people.
Anyway, if needed and it could be useful, I would start to work on this.
Cheers

@nvdaes

nvdaes commented Nov 10, 2018

Copy link
Copy Markdown
Collaborator

I created a branch that:

  • When emojis are checked, saves changes to an emojis-lang.dic file, which is always loaded as a profiles symbols file.
  • If an user (not a profile) symbol is added, that is, when emojis aren't checked, the symbol goes to user file, but if the symbols dialog is opened when emojis are checked, it will be saved as emoji.
    So, I think this is more consistent, but perhaps the remove button should be disabled for emojis even when they aren't checked in config.
    Also, this is a step to make possible to use different symbol dictionaries for different profiles with some changes.
    I will wait for your PR and when it's merged into master, if this is appropriate, I can follow creating a PR from
    https://github.com/nvdaes/nvda/tree/fixEmojiReplacement

Thanks

@LeonarddeR LeonarddeR changed the base branch from beta to master November 12, 2018 10:13
@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

I created a branch that:

* When emojis are checked, saves changes to an emojis-lang.dic file, which is always loaded as a profiles symbols file.

Problem with this is that you do not know whether you're editing an emoji o regular symbol. We somehow need to save the source of a symbol to have an edited instance saved in the proper user dictionary.

@nvdaes

nvdaes commented Nov 12, 2018

Copy link
Copy Markdown
Collaborator

leonardder commented

Problem with this is that you do not know whether you're editing an emoji o regular symbol. We somehow need to save the source of a symbol to have an edited instance saved in the proper user dictionary.

In _getSpeechSymbolsForLocale(locale):

This code is included:
emojis = SpeechSymbols()
if config.conf['speech']['includeCLDR']:
# Try to load CLDR data when processing is on.
# Load the data before loading other symbols,
# in order to allow translators to override them.
try:
builtin.load(os.path.join("locale", locale, "cldr.dic"),
allowComplexSymbols=False)
emojis = builtin

...
return builtin, user, profileSymbols, emojis

emojis takes the value of added emojis when they are checked in config. Anyway, I have thought about adding a checkbox or combo box to determine if a symbol should be added to user or profileSymbols, if profiles would be supported.
Not sure if this addresses the problem.

@LeonarddeR LeonarddeR changed the base branch from master to beta November 29, 2018 07:32
@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@michaelDCurran: This is now also reported in #8758 (comment)

I changed the base branch back to beta. It might make sense to have this workaround in 2018.4. We can leave out the changes file entry?

@michaelDCurran michaelDCurran merged commit 296b0c3 into nvaccess:beta Nov 29, 2018
@nvaccessAuto nvaccessAuto added this to the 2018.4 milestone Nov 29, 2018
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.

4 participants