Skip to content

Writing '.' at end of an identifier prepended to another identifier on android causes duplication of code #931

@MichaelRFairhurst

Description

@MichaelRFairhurst

Describe the issue

I've noticed a few odd behaviors using CodeMirror 6 on Android (with Chrome)

For this issue, the title says it pretty well. If I have an identifier "Column," and I begin prepending to it the identifier "EdgeInsets," so that the editor content is "EdgeInsets^Column" (where ^ is the cursor), then hitting '.' will result in the contents "EdgeInsets.Edgeinsets.ColumnColumn"

Here's a video of the issue:

https://photos.app.goo.gl/X7HoRtTW6Yfx63Eu8

It doesn't seem to happen with 100% regularity, but I can repro it with these exact steps:

Versions

        "@codemirror/language": "^6.2.1",
        "@codemirror/legacy-modes": "^6.1.0",
        "@rollup/plugin-node-resolve": "^13.3.0",
        "codemirror": "^6.0.1",
        "rollup": "^2.78.0"

Config

const updateListener = EditorView.updateListener.of((viewUpdate) => {
  if (viewUpdate.docChanged &&
      viewUpdate.transactions.some((t) => !t._skipListener)) {
    // Document changed and at least one transaction isn't marked to skip
    // this listener.
    const newValue = viewUpdate.state.doc.toString();
    if (window.codeEdited && window.codeEdited.postMessage) {
      window.codeEdited.postMessage(newValue);
    } else {
      console.warn('codeEdited.postMessage is not defined.');
    }
  }
});

const editor = new EditorView({
  doc: window.initCode,
  extensions: [
    basicSetup,
    StreamLanguage.define(dart),
    updateListener,
  ],
  parent: document.body,
});

Browser and platform

chrome on android

Reproduction link

https://storage.googleapis.com/scroll_animate_videos/editor.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions