Bug 570600 - [codemining] confusing cursor navigation with LineContentCodeMining
Summary: [codemining] confusing cursor navigation with LineContentCodeMining
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.14   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-24 02:37 EST by Christoph Laeubrich CLA
Modified: 2021-01-24 03:06 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Laeubrich CLA 2021-01-24 02:37:32 EST
I have a Codemining that uses LineContentCodeMining to insert an action inside a word. This leads to a little bit confusing cursor handling.

Say the Editor contains the content 'HelloWorld', the LineContentCodeMining is inserted between the two words the following happens (| = cursor position, []=selection):

1) The editor show HelloMiningWorld|
2) I place the cursor here now in front of the mining HelloMining|World
3) I now press the left-arrow key
4) The result is Hell|oMiningWorld
5) I press "delete", the result is Hell|World
6) I pres STRG+Z
7) the result is The result is Hell|[oMining]World

The expectation would be:
1) I can 'navigate over' the mining item with the cursor keys
2) redo an edit only marks the redo-text not the mining itself

----- code -----
public class BugCodeMiningProvider implements ICodeMiningProvider {

  private static final String CODE = "Mining";

  @Override
  public CompletableFuture<List<? extends ICodeMining>> provideCodeMinings(ITextViewer viewer,
      IProgressMonitor monitor) {
    return CompletableFuture.supplyAsync(() -> {

      IDocument document = viewer.getDocument();
      if (document.get().startsWith("HelloWorld")) {

        LineContentCodeMining mining = new LineContentCodeMining(
            new Position(5, CODE.length()),
            BugCodeMiningProvider.this) {

          @Override
          protected CompletableFuture<Void> doResolve(ITextViewer viewer,
                                               IProgressMonitor monitor) {
            return CompletableFuture.runAsync(() -> {
              super.setLabel(CODE);
            });
          }

        };
        return Collections.singletonList(
            mining);
      }
      return Collections.emptyList();
    });
  }

  @Override
  public void dispose() {

  }

}
Comment 1 Christoph Laeubrich CLA 2021-01-24 03:06:51 EST
If this is intentional I think it would be good to make it configurable so the mining can choose the behavior.