Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't modify loop control variable when looking for comments. #121

Closed
wants to merge 1 commit into from

2 participants

@DawidJanczak

Fixes #119 & #120, thanks to @doits, @kikyous and @xqin for initial reports.

The assignment [_, cur] = searchpos(...) modifies cur variable and does not increment it
if no result is found.
Use different variable name for searchpos return value and increase cur
at the end of loop.

Since this is my first time writing VimL please review this thoroughly - I'm pretty sure this is not the perfect solution.
Also I have no idea why this started occurring now - the plugin hasn't been changed recently. Might this be due to change in Vim itself somehow?

@DawidJanczak DawidJanczak Don't modify loop control variable when looking for comments.
The assignment [_, cur] modifies cur variable and does not increment it
if no result is found.
Use different variable name for searchpos return value and increase cur
at the end of loop.
2499bae
@CITguy CITguy referenced this pull request from a commit in CITguy/vim-coffee-script
@CITguy CITguy adding DawidJanczak patch for kchmck/vim-coffee-script issue #121 eb20263
@iangreenleaf iangreenleaf referenced this pull request from a commit in iangreenleaf/vim-coffee-script
@CITguy CITguy adding DawidJanczak patch for kchmck/vim-coffee-script issue #121 c13aa22
@kchmck kchmck closed this
@kchmck
Owner

For future bug searchers, please see #120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 1, 2013
  1. @DawidJanczak

    Don't modify loop control variable when looking for comments.

    DawidJanczak authored
    The assignment [_, cur] modifies cur variable and does not increment it
    if no result is found.
    Use different variable name for searchpos return value and increase cur
    at the end of loop.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 4 deletions.
  1. +6 −4 indent/coffee.vim
View
10 indent/coffee.vim
@@ -208,15 +208,17 @@ function! s:FindComment(linenum)
while cur != end
call cursor(0, cur + 1)
- let [_, cur] = searchpos('#', 'cn', a:linenum)
+ let [_, column] = searchpos('#', 'cn', a:linenum)
- if !cur
+ if !column
break
endif
- if s:IsComment(a:linenum, cur)
- return cur
+ if s:IsComment(a:linenum, column)
+ return column
endif
+
+ let cur = cur + 1
endwhile
return 0
Something went wrong with that request. Please try again.