Re: [code] [textadept] Block comments

From: Richard Philips <richard.philips.att.gmail.com>
Date: Mon, 20 May 2013 18:16:19 +0200

> Thanks for the report and solution. However, toggling block comment
> for multiple lines does not update the anchor position (beginning of
> the selection) appropriately. Do you have any ideas there?
>
> Cheers,
> Mitchell

Hi Mitchell,

Let us go for the simple solution :-)

We apply the same trick to the anchor as to the caret,
but we take the distance from the end of the line (with a twist)

So, before starting the loop:

   local p_origin = buffer.length - pos
   local a_origin = buffer.line_end_position[s] - anchor

After the loop, we calculate anchor and pos again:

   anchor = buffer.line_end_position[s] - a_origin
   -- make anchor stay on the right line in case of uncomment
   if buffer:position_from_line(s) > anchor then
      anchor = buffer:position_from_line(s)
   end
   pos = buffer.length - p_origin

Richard

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Mon 20 May 2013 - 12:16:19 EDT

This archive was generated by hypermail 2.2.0 : Tue 21 May 2013 - 06:42:30 EDT