Skip to content

EditorView.clickAddsSelectionRange using alt causes weird behaviors #972

@lishid

Description

@lishid

Describe the issue

When using clickAddsSelectionRange to change the multiple selection behavior from using Ctrl to use Alt, there are several things that stops working:

  • Adding a cursor by clicking on the empty area of the line doesn't work.
  • Adding a cursor by clicking on the empty area of a wrapped line causes the first line to be selected.

CodeMirror try repro

import {basicSetup, EditorView} from "codemirror"
import {javascript} from "@codemirror/lang-javascript"

new EditorView({
  doc: "console.log('hello')console.log('hello')console.log('hello')console.log('hello')console.log('hello')console.log('hello')console.log('hello')console.log('hello')console.log('hello')\nconsole.log('hello')\nconsole.log('hello')\nconsole.log('hello')\nconsole.log('hello')\n",
  extensions: [basicSetup, javascript(),
               EditorView.lineWrapping,
    EditorView.clickAddsSelectionRange.of(evt => evt.altKey && !evt.ctrlKey && !evt.metaKey)],
  parent: document.body
})

Video: Note I am holding down Alt the entire time.
test

Browser and platform

Windows/Chrome

Reproduction link

No response

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