Bookmarks

From: Brian Schott <brian-sch....at.cox.net>
Date: Sat, 21 Feb 2009 16:46:10 -0600

I've found some bugs in the bookmarks lua module.

Line 41 of bookmarks.lua tests markers for an even/odd number, but
setting the bookmark flag seems to set markers to 2, so it always thinks
that the line is not bookmarked, and thus always sets the bookmarking to
true. I worked around this by simply checking if the value is 2, but
that will fail if any other flags are set in addition to the bookmark.

-------------------------------------------------------------------
function toggle()
   local buffer = buffer
   local line = buffer:line_from_position(buffer.current_pos)
   local markers = buffer:marker_get(line) -- bit mask
   if markers == 2 then remove() else add() end -- first bit is set?
end
-------------------------------------------------------------------

The next bug is in the goto_next function. This doesn't wrap around, so
the user has to make another key binding to goto_prev. I hacked around
this by modifying it like so:

-------------------------------------------------------------------
function goto_next()
   local buffer = buffer
   local current_line = buffer:line_from_position(buffer.current_pos)
   local line = buffer:marker_next(current_line + 1, 2^MARK_BOOKMARK)
   if line >= 0 then
     _m.textadept.editing.goto_line(line + 1)
   else
     line = buffer:marker_next(0, 2^MARK_BOOKMARK)
     _m.textadept.editing.goto_line(line + 1)
   end
end
-------------------------------------------------------------------

Brian
Received on Sat 21 Feb 2009 - 17:46:10 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:37:32 EST