Machinery text replaces text in source editor instead of just adding it
This issue was created automatically by a script.
Bug 1682137
Bug Reporter: @abowler2 CC: @mathjazz
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:83.0) Gecko/20100101 Firefox/83.0
Steps to reproduce:
Selected an entry in order to 'Copy into translation' from the machinery tab
Actual results:
When in the standard FTL view (table view) the editor text is replaced instead of just added to.
Expected results:
The text from the machinery tab should have just been added to the editor rather than replacing the editor contents.
Comment Author: @abowler2
I found an older branch in my local environment from before the editor changes, and after testing things out on that branch I see that the behavior in the standard FTL view (table view) is correct.
However, when changing to the advanced FTL view the entire contents of the editor are replaced with the text from machinery, including the Fluent syntax. In addition the editor crashes when trying to switch back to the standard FTL view.
Comment Author: @mathjazz
I have second thoughts about this one. Why should we add, instead of replace text?
Here are some of the examples I've looked at: https://pontoon.mozilla.org/sl/firefox/all-resources/?string=200662 https://pontoon.mozilla.org/sl/firefox/all-resources/?string=200849 https://pontoon.mozilla.org/sl/firefox/all-resources/?string=192297
We feed Machinery with the simple preview of the source string, which is typically the default variant. That means the results offered by the Machinery are useful as is or with small modifications. Unlike with Concordance Search, where one could search for a term, which is part of a string.
April, could you remind us what was the motivation to file this bug?
Comment Author: @abowler2
Created attachment 9235904 Machinery replaces contents and crashes after
Here is the behavior that this bug was attempting to describe. This is with Machinery terms and not search results, though the same behavior happens with search terms too.
Attached file: Machinery-FTL.mov (video/quicktime, 6727619 bytes) Description: Machinery replaces contents and crashes after
Comment Author: @mathjazz
Thanks for clarifying! I thought the bug was about the Rich Editor (not Source Editor).
So instead of replacing text as it happens when copying from the Locales tab, we should add Machinery results to the source editor as we already do for Terms, Placeables and Concordance Search results.
In the meanwhile we have changed the behavior of copying strings from Machinery. Text is now replaced in both, the rich editor field or the source editor, but we always make sure the resulting Fluent message is valid. For example, when a value is copied to the source editor, that results in the following content: source-string-id = Copied value.