[TxMt] Strange Find and Replace Bug

Benjamin Linton ben at visiblebits.com
Thu Feb 16 22:05:40 UTC 2006


Here's a solution that might help you solve my issue:

<Soryu> ok try the following
<Soryu> select the text to find and press cmd-e
<Soryu> select the text to replace it with and cmd-shift-e
<Soryu> make the replacment selection
<Soryu> and invoke from the menu: edit->find->replace all in selection
<Soryu> does this still bring the bug?
<blinton> the bug does not occur
<Soryu> interesting, can you make a followup mail?
<blinton> sure

The dirty details:
> Original text block, a block section of my code:
> -------------------------------------------------
>
>   # Start a task
>   def start_task    
>     
>     # capture the time now so all timers match up
> (8) :now = Time.now
>     # find currently selected task
>     :selected_task = @user.selected_task
>     
>     # if a selected task exists
>     if :selected_task
>       # if the recently started task is already the selected task
>       if :selected_task.id == params[:id]
>         if :selected_task.status == 2
>           # notice - can't start a timer that is already running
>         elsif :selected_task.status == 1
>           # start the master timer, if necessary
>           unless @user.master_timer_is_running?
>             @user.start_master_timer
>           end
>           # start a new task timer timer
>           TaskTimer.create :started_at => :now, 
>                            :user_id => @user.id, 
>                            :task_id = :selected_task.id
>           # change status of the this task
>           :selected_task.status = 2
>           :selected_task.save
>         else
>           # error - stopped tasks can't be selected
>         end
>       # if the recently started task is not already the selected task    
>       else
>         # stop the task timer if it's still running
>         if :selected_task.status == 2
>           :task_timer = TaskTimer.find(:first,
>                                        :condition => "ended_at is null and " +
>                                                      "user_id = #{@user.id} and " +
>                                                      "task_id = #{:selected_task.id}")
>           :task_timer.ended_at = :now
>           :task_timer.save
>         end
>         #change status of selected task to stopped
>         :selected_task.status = 0
>         :selected_task.save
>         # find the newly started task
>         :selected_task = Task.find(params[:id])
>         # start the master timer, if necessary
>         unless @user.master_timer_is_running?
>           @user.start_master_timer
>         end
>         # start a new task timer
>         TaskTimer.create :started_at => :now, 
>                          :user_id => @user.id, 
>                          :task_id = params[:id]
>         # change status of the this task
>         :selected_task.status = 2
>         :selected_task.save
>       end
>     # if no selected task exists
>     else  
>       # find the newly selected task
>       :selected_task = Task.find(params[:id])
>       # start the master timer, if necessary
>       unless @user.master_timer_is_running?
>         @user.start_master_timer
>       end
>       # start a new task timer timer
>       TaskTimer.create :started_at => :now, 
>                        :user_id => @user.id, 
>                        :task_id = params[:id]
>       # change status of the this task
>       :selected_task.status = 2
>       :selected_task.save
>     end
>
>     redirect_to :action => 'index'
>   end
>
> -----------------------------------------------
>
> I make a full line selection on line #8.  I hit CMD+F and hold shift to do a selection only find/replace.
>
> I replace the word ":now" with "now" and here is what happens.  Notice that it not only screws up line #8, but also duplicates text down below line #164.  Strange!
>
> -----------------------------------------------
>
>   # Start a task
>   def start_task    
>     
>     # capture the time now so all timers match up
>     now
>     # capture the time now so all timers match up
> (8) :now = Time.now
>     # find currently selected task
>     :selected_task = @user.selected_task
>     
>     # if a selected task exists
>     if :selected_task
>       # if the recently started task is already the selected task
>       if :selected_task.id == params[:id]
>         if :selected_task.status == 2
>           # notice - can't start a timer that is already running
>         elsif :selected_task.status == 1
>           # start the master timer, if necessary
>           unless @user.master_timer_is_running?
>             @user.start_master_timer
>           end
>           # start a new task timer timer
>           TaskTimer.create :started_at => :now, 
>                            :user_id => @user.id, 
>                            :task_id = :selected_task.id
>           # change status of the this task
>           :selected_task.status = 2
>           :selected_task.save
>         else
>           # error - stopped tasks can't be selected
>         end
>       # if the recently started task is not already the selected task    
>       else
>         # stop the task timer if it's still running
>         if :selected_task.status == 2
>           :task_timer = TaskTimer.find(:first,
>                                        :condition => "ended_at is null and " +
>                                                      "user_id = #{@user.id} and " +
>                                                      "task_id = #{:selected_task.id}")
>           :task_timer.ended_at = :now
>           :task_timer.save
>         end
>         #change status of selected task to stopped
>         :selected_task.status = 0
>         :selected_task.save
>         # find the newly started task
>         :selected_task = Task.find(params[:id])
>         # start the master timer, if necessary
>         unless @user.master_timer_is_running?
>           @user.start_master_timer
>         end
>         # start a new task timer
>         TaskTimer.create :started_at => :now, 
>                          :user_id => @user.id, 
>                          :task_id = params[:id]
>         # change status of the this task
>         :selected_task.status = 2
>         :selected_task.save
>       end
>     # if no selected task exists
>     else  
>       # find the newly selected task
>       :selected_task = Task.find(params[:id])
>       # start the master timer, if necessary
>       unless @user.master_timer_is_running?
>         @user.start_master_timer
>       end
>       # start a new task timer timer
>       TaskTimer.create :started_at => :now, 
>                        :user_id => @user.id, 
>                        :task_id = params[:id]
>       # change status of the this task
>       :selected_task.status = 2
>       :selected_task.save
>     end
> (164) = Time.now
>     # find currently selected task
>     :selected_task = @user.selected_task
>     
>     # if a selected task exists
>     if :selected_task
>       # if the recently started task is already the selected task
>       if :selected_task.id == params[:id]
>         if :selected_task.status == 2
>           # notice - can't start a timer that is already running
>         elsif :selected_task.status == 1
>           # start the master timer, if necessary
>           unless @user.master_timer_is_running?
>             @user.start_master_timer
>           end
>           # start a new task timer timer
>           TaskTimer.create :started_at => :now, 
>                            :user_id => @user.id, 
>                            :task_id = :selected_task.id
>           # change status of the this task
>           :selected_task.status = 2
>           :selected_task.save
>         else
>           # error - stopped tasks can't be selected
>         end
>       # if the recently started task is not already the selected task    
>       else
>         # stop the task timer if it's still running
>         if :selected_task.status == 2
>           :task_timer = TaskTimer.find(:first,
>                                        :condition => "ended_at is null and " +
>                                                      "user_id = #{@user.id} and " +
>                                                      "task_id = #{:selected_task.id}")
>           :task_timer.ended_at = :now
>           :task_timer.save
>         end
>         #change status of selected task to stopped
>         :selected_task.status = 0
>         :selected_task.save
>         # find the newly started task
>         :selected_task = Task.find(params[:id])
>         # start the master timer, if necessary
>         unless @user.master_timer_is_running?
>           @user.start_master_timer
>         end
>         # start a new task timer
>         TaskTimer.create :started_at => :now, 
>                          :user_id => @user.id, 
>                          :task_id = params[:id]
>         # change status of the this task
>         :selected_task.status = 2
>         :selected_task.save
>       end
>     # if no selected task exists
>     else  
>       # find the newly selected task
>       :selected_task = Task.find(params[:id])
>       # start the master timer, if necessary
>       unless @user.master_timer_is_running?
>         @user.start_master_timer
>       end
>       # start a new task timer timer
>       TaskTimer.create :started_at => :now, 
>                        :user_id => @user.id, 
>                        :task_id = params[:id]
>       # change status of the this task
>       :selected_task.status = 2
>       :selected_task.save
>     end
>
>     redirect_to :action => 'index'
>   end
>
> -----------------------------------------------
>
> I am using r906 (latest).  Ignore and wrap are on.  Reg exp. is off.
>
> ------------------------------------------------------------------------
>
>
> Soryu.
>
> ------------------------------------------------------------------------
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate




More information about the textmate mailing list