JetBrains / MPS-extensions

MPS-extensions aims to ease language development within MPS.
https://jetbrains.github.io/MPS-extensions/
Apache License 2.0
80 stars 47 forks source link

Issues if richtext Text node is shown in two editor cells. #769

Open malueck opened 5 months ago

malueck commented 5 months ago

If a richtext Text node is shown in two cells, all sorts of problems appear. A simple case to reproduce is in a collection with just the Text nodes:

[/
   %Text%
   %Text%
/]

Found in MPS-richtext 2022.2.

alexanderpann commented 5 months ago

I've tested it with a simple editor with two text nodes as in the example and I can't reproduce those issues.

For me, it sounds like you are using the query list language and are showing the same node multiple times in the same editor. Then it is a known limitation that can only be influenced but not fixed by the duplicates safe property. The reason why it happens in those cases is that in some situations, the big cell (= top-most cell) of a node is queried from the editor component instead of direct usages of the correct editor cell. It always finds the cell for the second node and not the first one, that's why all the actions are working for the second text node.

If you are sure that it is a problem in the richtext language, you have to provide me with a sample project, so I can check it out.

malueck commented 5 months ago

mps_example

Querylist is not involved in this problem. A made a small example.

Version info: MPS 2022.2.2 Build #MPS-222.4554.1547, built on December 13, 2023 Runtime version: 17.0.6+7-b469.82 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

The plugin "MPS Richtext Editor Component" is from the Marketplace i.e. in the "Downloaded" section of installed plugins and enabled.

I disabled all plugins except the dependencies of MPS Richtext and created a dummy concept. You can see the editor in the screenshot. It has two cells for the same Text child and two cells for a multiline property.

Observations:

malueck commented 5 months ago

Example project as a zip file.

Project2.zip

Concept definition:

concept Dummy extends BaseConcept                                                                                                                                                
              implements <none>                                                                                                                                                  

    instance can be root: true 
alias: <no alias> 
short description: <no short description> 

properties: 
str : string  

children: 
Text : Text[1] 

references: 
<< ... >>

Editor:


<default> editor for concept Dummy
    node cell layout:             
         [/                       
         % Text %                 
         % Text %                 
         <constant>               
         { str }\n                
         { str }\n                
         /]                       

    inspected cell layout:        
        <choose cell model>       
alexanderpann commented 5 months ago

I just checked the implementation. To summarize in case we want to fix this: