Vim Tips Wiki
Register
Edit Page
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 7: Line 7:
 
I've also found the bug "Out of range errors" just like what's described in that bug report, read as "Hanoi gives out of range errors (list element -1) after moving the cursor to an empty pole, and stops."
 
I've also found the bug "Out of range errors" just like what's described in that bug report, read as "Hanoi gives out of range errors (list element -1) after moving the cursor to an empty pole, and stops."
   
To fix this bug, I've read the script and found a leak when process <code>PoleMoveDisk</code>. It forgot to determine the condition that the target pole to select (i.e. to move to) should have disks when selecting a pole!
+
To fix this bug, I've read the script and found a leak when process <tt>PoleMoveDisk</tt>. It forgot to determine the condition that the target pole to select (i.e. to move to) should have disks when selecting a pole!
   
So to fix it, I make up the condition determination in <code>function! s:play()</code> at row 266/271 in script file <code>autoload/hanoi.vim</code> by adding statement:
+
So to fix it, I make up the condition determination in {{tt|function! s:play()}} at row 266/271 in script file <tt>autoload/hanoi.vim</tt> by adding statement:
   
<code>if s:curpole.next.NOD() > 0</code> and adding <code>endif</code> after statement <code>call s:PoleSelectPole(s:curpole.next/prev)</code> to close <code>if</code> statement.
+
{{tt|if s:curpole.next.NOD() > 0}} and adding <tt>endif</tt> after statement {{tt|call s:PoleSelectPole(s:curpole.next/prev)}} to close <tt>if</tt> statement.
   
To be more robust, I add another condition determination statement in <code>function! s:PoleSelectPole(newPole)</code> at row 508 in script file <code>autoload/hanoi.vim</code> by adding <code> && a:newPole.NOD() > 0</code> in the if statement <code>if s:curpole != a:newPole </code>. Of course, this supplement is optional if the above leak has been fixed.
+
To be more robust, I add another condition determination statement in {{tt|function! s:PoleSelectPole(newPole)}} at row 508 in script file <tt>autoload/hanoi.vim</tt> by adding {{tt| && a:newPole.NOD() > 0}} in the if statement {{tt|1=if s:curpole != a:newPole }}. Of course, this supplement is optional if the above leak has been fixed.
   
 
Hope the author fix the bug and offer the latest copy for downloading. --[[Special:Contributions/218.189.38.36|218.189.38.36]] 05:39, November 23, 2011 (UTC)
 
Hope the author fix the bug and offer the latest copy for downloading. --[[Special:Contributions/218.189.38.36|218.189.38.36]] 05:39, November 23, 2011 (UTC)
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel Editing help (opens in new window)

Template used on this page: