| Author |
Message |
Index > Bug Reports ~ Comment Line / Selection command is broken |
| charlesroper |
Posted: Fri Oct 03, 2008 6:12 am |
|
|
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 becomesCode: # def create
# map_params_before_save(params)
# @occurrence = Occurrence.new(params[:occurrence])
# lookup_autocomplete_ids(params)
#
# respond_to do
Not good. |
|
|
| Back to top |
|
| Miggles |
Posted: Wed Oct 15, 2008 8:09 am |
|
|
|
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
- I select to the end of the last line of the set I want to comment: works fine.
- 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.
- I delete the two spaces off that line and repeat step 2: works fine.
- 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). |
|
|
| Back to top |
|
| Alexander Stigsen |
Posted: Wed Oct 15, 2008 10:07 am |
|
|
|
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. |
|
|
| Back to top |
|
| Miggles |
Posted: Thu Oct 16, 2008 8:18 am |
|
|
|
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. |
|
|
| Back to top |
|
| cgrindel1 |
Posted: Thu Oct 16, 2008 1:14 pm |
|
|
|
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? |
|
|
| Back to top |
|
| cgrindel1 |
Posted: Thu Oct 16, 2008 1:31 pm |
|
|
|
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
|
|
|
| Back to top |
|
| charlesroper |
Posted: Fri Oct 17, 2008 6:27 am |
|
|
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. |
|
|
| Back to top |
|
| Miggles |
Posted: Fri Oct 17, 2008 8:28 am |
|
|
|
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? |
|
|
| Back to top |
|
|
|