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

There should be no errors when indenting a code block #5910

Closed
oleq opened this issue Dec 5, 2019 · 3 comments
Closed

There should be no errors when indenting a code block #5910

oleq opened this issue Dec 5, 2019 · 3 comments
Labels
package:code-block resolution:duplicate This issue is a duplicate of another issue and was merged into it. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@oleq
Copy link
Member

oleq commented Dec 5, 2019

📝 Provide detailed reproduction steps (if any)

  1. Go to the code blocks guide/manual test.
  2. Call
editor.setData( `<pre><code class="language-css">	}
}</code></pre>` );
  1. Select all the content (Ctrl+A) then click "Indent"

✔️ Expected result

The content is indented.

❌ Actual result

An error is thrown:

remove.js:16 Uncaught TypeError: Cannot read property 'parentNode' of undefined
    at remove (remove.js:16)
    at Renderer._updateChildren (renderer.js:557)
    at Renderer.render (renderer.js:203)
    at View._render (view.js:682)
    at View.<anonymous> (view.js:187)
    at View.fire (emittermixin.js:209)
    at View.change (view.js:479)
    at View._disableRendering (view.js:669)
    at Model.EditingController.listenTo.priority (editingcontroller.js:84)
    at Model.fire (emittermixin.js:209)

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@oleq oleq added type:bug This issue reports a buggy (incorrect) behavior. status:confirmed package:code-block labels Dec 5, 2019
@oleq
Copy link
Member Author

oleq commented Dec 5, 2019

After a quick check, it looks like an engine bug. What indent command does is inserting a tab \t at these two positions [ 0, 3 ] and [ 0, 1 ] (in this exact order):

image

It uses writer.insertText(). When I change \t into a letter (anything non–whitespace) the error is gone. The stack trace goes into the renderer so there's some white-space optimization there that fails.

@oleq
Copy link
Member Author

oleq commented Dec 5, 2019

Note: When you use

<pre><code class="language-css">	x
x</code></pre>

there will be an error. But when you use

<pre><code class="language-css">	x
y</code></pre>

no error is thrown. My guess is something's wrong with the node lists diffing. In the first case, the diff is

["insert", "insert", "equal", "delete", "delete"]

and in the second

["insert", "delete", "equal", "insert", "delete"]

while actualDomChildren and expectedDomChildren make sense in both cases. I think we had this kind of issue in the past (1 character diffs having problems telling which char is which). @Reinmar do you remember what it was?

@Reinmar
Copy link
Member

Reinmar commented Jan 21, 2020

It seems that it's related to couple other issues that we've seen. Closing for now as DUP of #6092.

@Reinmar Reinmar closed this as completed Jan 21, 2020
@Reinmar Reinmar removed this from the iteration 29 milestone Jan 21, 2020
@Reinmar Reinmar added the resolution:duplicate This issue is a duplicate of another issue and was merged into it. label Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:code-block resolution:duplicate This issue is a duplicate of another issue and was merged into it. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

2 participants