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

Addons bookmark refresh fix #284

Merged
merged 2 commits into from
Sep 20, 2015
Merged

Conversation

eht16
Copy link
Member

@eht16 eht16 commented Sep 16, 2015

Update bookmark list also on any line changes in the document

In addition to updating the bookmark list on document notebook tab change
and adding/removing line markers, also rebuild the bookmark list
when the text in the document changes with lines added or deleted.

Should fix SF bugs 129 and 39.

This implements some ideas mentioned in the above bug reports like updating the bookmark list
in an idle callback. Additionally, the list store is detach from the GtkTreeView to increase performance on big bookmark lists.

Maybe it is still worth to add a refresh button (or rather a context menu item to refresh) but I would try it without at first.

There is one issue left: if the Transpose current line feature is used, the bookmarks don't update. But this is not a problem in the plugin but rather in either Geany or Scintilla as the marker also stays at the "old" line. This should be managed separately.

@codebrainz
Copy link
Member

LGTM, though I didn't test.

typedef struct
{
AoBookmarkList *bm;
GeanyDocument *document;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might want to use Document IDs as you delay the reference to the document. It probably doesn't matter much in practice though, it's highly unlikely a document is reused during the delay.

@b4n
Copy link
Member

b4n commented Sep 18, 2015

Otherwise, as @codebrainz, I didn't test but it LGTM

@eht16 eht16 force-pushed the addons_bookmark_refresh_fix branch from a47cb83 to f497d9d Compare September 18, 2015 17:51
@eht16
Copy link
Member Author

eht16 commented Sep 18, 2015

Thanks for the feedback.

I changed the document referencing to IDs as suggested.

Refreshing the treeview with about 5000 markers set takes about 40-50ms with de- and reattching the model. Without detaching, refreshing takes about 60-70ms, on my machine.
So it is actually not that big difference and I doubt users will click that many markers. I cheated a bit by programatically setting them on startup :).

So, as the difference is actually not really big, I removed commit 0d130be. However, I could not notice any flickering, with or without the commit.

AoBookmarkListPrivate *priv = AO_BOOKMARK_LIST_GET_PRIVATE(bm);
GeanyDocument *doc = document_find_by_id(container->document_id);
ScintillaObject *sci = doc->editor->sci;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic error: you dereference doc here, but check whether it's NULL on the next line.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to try to compile this. I assume the fix here is this? (edit: all built AOK, including this change)

GeanyDocument *doc = document_find_by_id(container->document_id);

if (doc != NULL && priv->enable_bookmarklist)
{
    ScintillaObject *sci = doc->editor->sci;
// etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Fixed in 8ab3ee2.

@b4n
Copy link
Member

b4n commented Sep 20, 2015

LGTM

@eht16 eht16 force-pushed the addons_bookmark_refresh_fix branch from e8c0dcc to 3d3df5c Compare September 20, 2015 14:59
@eht16
Copy link
Member Author

eht16 commented Sep 20, 2015

I added eht16@e8c0dcc to add the newlines and squashed unimportant commits together.

@eht16
Copy link
Member Author

eht16 commented Sep 20, 2015

And it seems I pulled too many commits into the rebase. Can this get problematic when merging?

@b4n
Copy link
Member

b4n commented Sep 20, 2015

yes, it very well might. But you should be able to fix that fairly easily to fix: check master out, pull (fast-forward, pull --ff-only) from upstream, and rebase your branch on top of that. Or you can also just rebase -i 8234f7c^ and remove the two offending/duplicate commits, only keeping yours. As it's a separate branch, there won't be no problem.

@b4n
Copy link
Member

b4n commented Sep 20, 2015

@eht16 if you're interested, I just did the second solution as you didn't seem to update this already: https://github.com/b4n/geany-plugins/commits/eht16/addons_bookmark_refresh_fix ;)

This should delay updates on Scintilla events until the GLib main loop is
idling, assuming the typing or other text modifications are finished.
In addition to updating the bookmark list on document notebook tab change
and adding/removing line markers, also rebuild the bookmark list
when the text in the document changes with lines added or deleted.

Should fix SF bugs geany#129 and geany#39.
@eht16 eht16 force-pushed the addons_bookmark_refresh_fix branch from 3d3df5c to 0ecdc42 Compare September 20, 2015 20:21
@eht16
Copy link
Member Author

eht16 commented Sep 20, 2015

Thanks again for your help and sorry for unnecessary mistakes in code and GIT usage :(.

eht16 added a commit that referenced this pull request Sep 20, 2015
Update bookmark list also on any line changes in the document
    
In addition to updating the bookmark list on document notebook tab change
and adding/removing line markers, also rebuild the bookmark list
when the text in the document changes with lines added or deleted.
    
Should fix SF bugs #129 and #39.
@eht16 eht16 merged commit 38bf4b0 into geany:master Sep 20, 2015
@b4n
Copy link
Member

b4n commented Sep 20, 2015

np, that's what annoying reviews are for :)

@frlan frlan added this to the 1.26 milestone Sep 22, 2015
@eht16 eht16 deleted the addons_bookmark_refresh_fix branch October 11, 2015 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants