goLineLeft behaving incorrectly for wrapped lines
See original GitHub issueWhen goLineLeft
executed when cursor at the end of the visual line, it tends to go to the beginning of next one.
steps to repro:
-
go to http://codemirror.net/demo/indentwrap.html (again, demonstrating on indentwrap due to lack of pure lineWrapping demo, but applies to both)
-
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 );
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:
- Created 6 years ago
- Comments:5 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The output of
charCoords
for wrapped characters is pretty much undefined, since browsers do wildly different weird things for those. This is why we havecursorCoords
, 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?WTBS,
goLineLeftSmart
should use the same.