question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

goLineLeft behaving incorrectly for wrapped lines

See original GitHub issue

When goLineLeft executed when cursor at the end of the visual line, it tends to go to the beginning of next one.

steps to repro:

  1. go to http://codemirror.net/demo/indentwrap.html (again, demonstrating on indentwrap due to lack of pure lineWrapping demo, but applies to both)

  2. paste this into console and click back inside the editor within the 2s period

    setTimeout(() => { editor.setCursor({line: 4, ch: 71}); editor.execCommand("goLineLeft"); }, 2000 );
    

image

Similarly (but much less aggravating… in fact I think it’s a nice behavior), if goLineRight is executed at the end of a visual line, it goes to the end of the next visual line.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
marijnhcommented, Jul 10, 2017

The output of charCoords for wrapped characters is pretty much undefined, since browsers do wildly different weird things for those. This is why we have cursorCoords, which gives you the coordinates of an actual cursor position, which is easier to define.

Attached patch makes goLineRight stable (i.e. it stops advancing when the cursor is already at the end of the line). Does that solve the problem for you?

0reactions
dwellecommented, Jul 10, 2017

WTBS, goLineLeftSmart should use the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

goLineLeft behaving incorrectly for wrapped lines · Issue #4840
When goLineLeft executed when cursor at the end of the visual line, it tends to go to the beginning of next one. steps...
Read more >
When deleting a line, the final cursor position is incorrect for ...
The cursor goes to the line below the deleted line when a short line is deleted and to the line above the deleted...
Read more >
[misc] Current line highlight is incorrect for wrapped lines - Bugs
It is line based and hence the (document) model knows nothing about lines being wrapped by the widget. Current line highlighting is just...
Read more >
Word Wrap Problem | DP-19 - GeeksforGeeks
Put line breaks in the given sequence such that the lines are printed neatly. Assume that the length of each word is smaller...
Read more >
How to force the Eclipse Mars 4.5 formatter not to join already ...
That seems to be sufficient for my already wrapped lines not to be joined and keep the default behavior of the formatter to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found