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

Unexpected error: Failed to execute 'setStart' on 'Range': The offset 4294967292 is larger than the node's length (491). #2627

Open
nestoris opened this issue Aug 22, 2021 · 2 comments
Labels
🔭 area/muya 🐛 bug Something isn't working

Comments

@nestoris
Copy link

Description

An unexpected error occurred in the renderer process.

Stack Trace

Error: Failed to execute 'setStart' on 'Range': The offset 4294967292 is larger than the node's length (491).
    at Object.select (file:///usr/lib/marktext/app.asar/dist/electron/webpack:/src/muya/lib/selection/index.js:346:11)
    at Object.setCursorRange (file:///usr/lib/marktext/app.asar/dist/electron/webpack:/src/muya/lib/selection/index.js:491:10)
    at aa.setCursor (file:///usr/lib/marktext/app.asar/dist/electron/webpack:/src/muya/lib/contentState/index.js:205:15)
    at aa.partialRender (file:///usr/lib/marktext/app.asar/dist/electron/webpack:/src/muya/lib/contentState/index.js:257:12)
    at aa.inputHandler (file:///usr/lib/marktext/app.asar/dist/electron/webpack:/src/muya/lib/contentState/inputCtrl.js:324:51)
    at HTMLDivElement.<anonymous> (file:///usr/lib/marktext/app.asar/dist/electron/webpack:/src/muya/lib/eventHandler/keyboard.js:203:22)

Version

Mark Text: v0.16.3 (c1d603f)
Operating system: Linux x64 5.10.59-1-MANJARO (linux)

@Jocs
Copy link
Member

Jocs commented Dec 29, 2021

How to reproduce this issue?

@Jocs Jocs added the 🐤 blocked/need info Need more details about this issue or pull request label Dec 29, 2021
@fxha
Copy link
Contributor

fxha commented Jan 12, 2022

Description:

Merging two lines of white-spaces (here spaces) result in an editor crash because the spaces are converted into a code bock. The cursor is invalid after this operation and overflows when setting the cursor in DOM.

Steps:

Type in editor mode and set cursor the the given position:

  1. Type a and hit enter
  2. Type two or three spaces and hit enter
  3. Type two or three spaces and hit enter
  4. Type b and position cursor
  5. Press Shift, once ArrorLeft while holding shift and afterwards Backspace
a

2x <space>

<cursor>2x <space>

b

Cursor before crash:

{
  "start":{
    "key":"ag-105",
    "offset": -2
  },
  "anchor":{
    "key":"ag-105",
    "offset": -2
  },
  "end":{
    "key":"ag-105",
    "offset": -2
  },
  "focus":{
    "key":"ag-105",
    "offset": -2
  }
}

Expected behavior:

  • Either the code block is generated and the correct cursor should be set or
  • all spaces are replaced by one space and the cursor may be adjusted.

Temporary Workaround:

Validate cursor before setting and use a fallback.

Stack Trace:

index.js?4d53:346 Uncaught DOMException: Failed to execute 'setStart' on 'Range': The offset 4294967293 is invalid.
    at Selection.select (webpack-internal:///./src/muya/lib/selection/index.js:360:11)
    at Selection.setCursorRange (webpack-internal:///./src/muya/lib/selection/index.js:527:10)
    at ContentState.setCursor (webpack-internal:///./src/muya/lib/contentState/index.js:241:56)
    at ContentState.partialRender (webpack-internal:///./src/muya/lib/contentState/index.js:326:12)
    at ContentState.inputHandler (webpack-internal:///./src/muya/lib/contentState/inputCtrl.js:366:51)
    at HTMLDivElement.inputHandler (webpack-internal:///./src/muya/lib/eventHandler/keyboard.js:248:22)

@fxha fxha added 🐛 bug Something isn't working 🔭 area/muya and removed 🐤 blocked/need info Need more details about this issue or pull request labels Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔭 area/muya 🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants