Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZeroWidthSpace inserted when editing across lines #713

Closed
lishid opened this issue Feb 2, 2022 · 1 comment
Closed

ZeroWidthSpace inserted when editing across lines #713

lishid opened this issue Feb 2, 2022 · 1 comment

Comments

@lishid
Copy link

@lishid lishid commented Feb 2, 2022

Similar to #691

When selecting across multiple lines and typing something to replace the selection, ZeroWidthSpace characters generated from replacements and widgets shows up.

  • Open https://codemirror.net/6/ in Chrome.
  • Run the following code block in dev console.
  • Select from the first line to the second, just before the replacement (234\n1)
    image.
  • Type any character.
  • Observe red dot "Control character zero width space" showing up.
const {EditorState, EditorView, basicSetup} = CM["@codemirror/basic-setup"];
const {WidgetType, Decoration, ViewPlugin, highlightSpecialChars} = CM["@codemirror/view"];
const {RangeSetBuilder} = CM["@codemirror/rangeset"];
const {StateField} = CM["@codemirror/state"];
let text = '1234\n1234\n1234';
let decos = Decoration.set([Decoration.replace({}).range(6,8)]);
let plugin = ViewPlugin.define(view => {}, {decorations: v => decos});
let state = EditorState.create({
	doc: text,
	extensions: [basicSetup, highlightSpecialChars(), plugin]
});
view.setState(state);

test

@marijnh
Copy link
Member

@marijnh marijnh commented Feb 4, 2022

Heh, damn, I knew we'd have bugs like this. Attached patch makes the zero-width space stripping more aggressive.

marijnh added a commit to codemirror/view that referenced this issue Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants