E Text Editor | The Power of Textmate on Windows

 
Author Message

Index  >  Bug Reports  ~  Comment Line / Selection command is broken

charlesroper
Posted: Fri Oct 03, 2008 6:12 am Reply with quote
Registered User Joined: 06 Mar 2007 Posts: 1204 Location: UK
When I use the Comment Line / Selection command to comment out code, the code will often get eaten.

E.g., this:
Code:
  def create
    map_params_before_save(params)
    @occurrence = Occurrence.new(params[:occurrence])
    lookup_autocomplete_ids(params)

    respond_to do |format|           
      if @occurrence.save
        flash[:notice] = 'Occurrence was successfully created.'
        format.html { redirect_to(occurrences_url) }
        format.xml  { render :xml => @occurrence, :status => :created, :location => @occurrence }
      else
        prepare_occurrence_to_edit;
        format.html { render :action => "new" }
        format.xml  { render :xml => @occurrence.errors, :status => :unprocessable_entity }
      end
    end
  end
becomes
Code:
  # def create
  #   map_params_before_save(params)
  #   @occurrence = Occurrence.new(params[:occurrence])
  #   lookup_autocomplete_ids(params)
  #
  #   respond_to do


Not good.
View user's profile Send private message Visit poster's website
Miggles
Posted: Wed Oct 15, 2008 8:09 am Reply with quote
Registered User Joined: 24 Aug 2007 Posts: 21
I actually came here to mention this and the other commenting bug. I've made a small video so you can see them in action: http://screencast.com/t/5c6nT1Zf


  1. I select to the end of the last line of the set I want to comment: works fine.
  2. I select to the start of the following line (shift+down arrow): the indentation of all but the first commented line is out by two spaces. Why? Because there are two spaces on the apparently empty line below.
  3. I delete the two spaces off that line and repeat step 2: works fine.
  4. Finally, I demonstrate how block commenting ruby blocks results in disappearing code (regardless of how you select it).


This has been bugging me for a while now (unfortunately I can't remember which version broke it first).
View user's profile Send private message
Alexander Stigsen
Posted: Wed Oct 15, 2008 10:07 am Reply with quote
e Developer Joined: 31 Jul 2005 Posts: 468
This is the caused by the command outputting as snippet (to maintain selection) without escaping "|". This means that if the code contains a bar character, the tabstop will be interpreted as a snippet pipe.

The fix should be pretty easy. Just make it escape "|" (it already has to escape "}").

This will obviously be a problem that will reoccur with a few other commands that send their output as snippets, but I think that the power of the new syntax is worth it.
View user's profile Send private message Send e-mail Visit poster's website
Miggles
Posted: Thu Oct 16, 2008 8:18 am Reply with quote
Registered User Joined: 24 Aug 2007 Posts: 21
Thanks Alexander, that stops it from eating blocks.

I've tried to find what's causing it to bust the layout (as shown in my video) but have made very little progress. It seems to me that the extra indentation is being added by e. Any comments or advice on how to fix that?

PS. Crikey. That's some hard to read code in the comment bundle.
View user's profile Send private message
cgrindel1
Posted: Thu Oct 16, 2008 1:14 pm Reply with quote
Registered User Joined: 03 Dec 2007 Posts: 3
Thanks for the info, Alexander and Miggles. I am looking to make the change as well. Can you post the update to the bundle for escaping the '|'? I presume that this is in the Source bundle. Is that correct?
View user's profile Send private message
cgrindel1
Posted: Thu Oct 16, 2008 1:31 pm Reply with quote
Registered User Joined: 03 Dec 2007 Posts: 3
After a couple of sips of coffee, I think that I found the code to be updated in the Source bundle's "Comment Line/Selection".

Code:

# def out(*args)
#   print( *args.map do |arg|
#     escaped = e_sn(arg)
#     $selected ? escaped.gsub("}", "\\}") : escaped.sub("\0", "${0}")
#   end )
# end

def out(*args)
  print( *args.map do |arg|
    escaped = e_sn(arg)
    $selected ? escaped.gsub("}", "\\}").gsub("|", "\\|") : escaped.sub("\0", "${0}")
  end )
end
View user's profile Send private message
charlesroper
Posted: Fri Oct 17, 2008 6:27 am Reply with quote
Registered User Joined: 06 Mar 2007 Posts: 1204 Location: UK
Nice one, thanks! I've uploaded the fix to ebundles. Anyone can now fix this issue by going into the bundles manager (Bundles > Edit Bundles > Manage Bundles) and updating the Source bundle.
View user's profile Send private message Visit poster's website
Miggles
Posted: Fri Oct 17, 2008 8:28 am Reply with quote
Registered User Joined: 24 Aug 2007 Posts: 21
cgrindel1 wrote:
After a couple of sips of coffee, I think that I found the code to be updated in the Source bundle's "Comment Line/Selection".


That's exactly the fix I applied.

I must be missing a trick here because I found it quite difficult to debug what the bundles were doing (mainly for fixing the indentation when commenting issue).

Any tips for debugging bundles?
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
Post new topic

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum