atom / bookmarks

Bookmark editor lines in Atom
MIT License
49 stars 36 forks source link

Copying a bookmarked line creates fake bookmarks #62

Closed pdonias closed 8 years ago

pdonias commented 8 years ago

Copying and pasting a bookmarked line sometimes (I wasn't able to determine what's making it happen) creates a fake bookmark on the pasted line. Then, pressing F2 (jump key) from anywhere in the file selects both lines.

capture du 2016-06-13 10-53-19

And pressing F1 (toggle bookmark key) on one of the lines sometimes removes both bookmarks, and sometimes doesn't do anything (it might depend on which one is the "fake" bookmark).

Details: OS: Ubuntu 4.2.0-38-generic Atom version: 1.8.0 bookmarks version: 0.39.0

solendil commented 8 years ago

Just wanted to say that the blue symbols in the left gutter can be misleading: a bookmark is not just a line, it's a text selection, that can span multiple lines. You can create a multi-line bookmark which will behave the way you describe (F2 selects both lines, F2 on one of these lines removes both, etc...)

What you describe about the copy/paste creating a second bookmark seems to be a bug, though. But I couldn't reproduce it.

revelt commented 8 years ago

Here's a recreation of the fake bookmarks:

fake_bookmarks_upon_pasting

It's enough just to paste multiple rows onto a bookmarked line. At least multiple bookmarks are not real, it's enough to toggle the bookmark and they go away. What's annoying is bug #69 — jump to bookmark.

I'm on Bookmarks 0.42@Atom 1.11.2@Mac.

Ben3eeE commented 8 years ago

You don't even have to paste to create the bookmarks. Just keep typing after a bookmarked line creates them for me.

bookmarked lines

revelt commented 8 years ago

@Ben3eeE Yes that too, and it has something to do with the beginning of the line. Check this out:

false_bookmarks

Ben3eeE commented 8 years ago

Actually it only creates the bookmark when adding newlines in the beginning of the line if you had the cursor in the beginning of the line when adding the bookmark.

For longer lines this is what happens:

bookmarked lines v2

Ben3eeE commented 8 years ago

Also, thank you for the gifs to help reproduce @revelt. Much appreciated :bowing_man:

pdonias commented 8 years ago

@Ben3eeE I don't seem to have the exact same behaviour here:

atombug

revelt commented 8 years ago

@pdonias Like Linus said, it's dependent where you created the original bookmark. Here I create bookmark after "1", and only there it duplicates:

location_dependent

Looks like bookmarks are based on certain invisible character which gets messed up on editing its vicinity.

pdonias commented 8 years ago

@revelt OK, my bad. I have the same behaviour.

Ben3eeE commented 8 years ago

Actually there is a small difference in the gif by @pdonias :wink:. If you add characters after adding the bookmark all of these characters creates the duplicated bookmark on newline.

bookmarked lines v3

revelt commented 8 years ago

+1 I was able to reproduce it. Adding characters on the same line after bookmarking is also a bug factor.

pdonias commented 8 years ago

As @solendil said, a bookmark is a range.

@markerLayer.markBufferRange(range, {invalidate: 'surround'})

So it has a head and a tail (head and tail can be at the same position) and when we add content in between those 2 bounds (head and tail included), it will make the bookmarked range bigger. Every line containing a part of the range will have the blue icon.

Wouldn't it make more sense if a bookmark was just a line?

revelt commented 8 years ago

jumping to a bookmark would always place the cursor to the beginning of the line

But Sublime manages to jump exactly where the bookmark was placed! Often code spans multiple lines, and jumping to exact spot would be enormously helpful.

pdonias commented 8 years ago

OK, I understand. So if you want to match Sublime's behaviour, some changes need to be done:

There are probably more, but I think this would be enough to fix the weird behaviour we have right now :)