mirror of
				https://github.com/jiangmiao/auto-pairs.git
				synced 2025-11-04 11:29:22 +08:00 
			
		
		
		
	Fix #235, result in iabbrev behavior error
This commit is contained in:
		@ -215,9 +215,8 @@ func! AutoPairsInsert(key)
 | 
				
			|||||||
  endfor
 | 
					  endfor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  " check open pairs
 | 
					  " check open pairs
 | 
				
			||||||
  let text=before.a:key
 | 
					 | 
				
			||||||
  for [open, close, opt] in b:AutoPairsList
 | 
					  for [open, close, opt] in b:AutoPairsList
 | 
				
			||||||
    let ms = s:matchend(text, open)
 | 
					    let ms = s:matchend(before.a:key, open)
 | 
				
			||||||
    if len(ms) > 0
 | 
					    if len(ms) > 0
 | 
				
			||||||
      " process the open pair
 | 
					      " process the open pair
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
@ -227,37 +226,39 @@ func! AutoPairsInsert(key)
 | 
				
			|||||||
      " <?php ?> should backspace 4 times php and <?
 | 
					      " <?php ?> should backspace 4 times php and <?
 | 
				
			||||||
      let target = ms[1]
 | 
					      let target = ms[1]
 | 
				
			||||||
      let openPair = ms[2]
 | 
					      let openPair = ms[2]
 | 
				
			||||||
      let text = before
 | 
					 | 
				
			||||||
      let i = 0
 | 
					      let i = 0
 | 
				
			||||||
      while len(text) >= len(target) && target != text 
 | 
					      let bs = ''
 | 
				
			||||||
 | 
					      let del = ''
 | 
				
			||||||
 | 
					      while len(before) >= len(target) && target != before
 | 
				
			||||||
        let found = 0
 | 
					        let found = 0
 | 
				
			||||||
        " delete pair
 | 
					        " delete pair
 | 
				
			||||||
        for [o, c, opt] in b:AutoPairsList
 | 
					        for [o, c, opt] in b:AutoPairsList
 | 
				
			||||||
          let ms = s:matchend(text, o)
 | 
					          let ms = s:matchend(before, o)
 | 
				
			||||||
          if len(ms) > 0
 | 
					          if len(ms) > 0
 | 
				
			||||||
            let found = 1
 | 
					            let found = 1
 | 
				
			||||||
            let text = ms[1]
 | 
					            let before = ms[1]
 | 
				
			||||||
            let i = i + 1
 | 
					            " delete open pair
 | 
				
			||||||
 | 
					            let bs = bs.s:backspace(ms[2])
 | 
				
			||||||
 | 
					            " delete close pair
 | 
				
			||||||
 | 
					            let ms = s:matchbegin(afterline, c)
 | 
				
			||||||
 | 
					            if len(ms) > 0
 | 
				
			||||||
 | 
					              let del = del.s:delete(ms[1])
 | 
				
			||||||
 | 
					              let afterline = ms[2]
 | 
				
			||||||
 | 
					            end
 | 
				
			||||||
            break
 | 
					            break
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
        endfor
 | 
					        endfor
 | 
				
			||||||
        if !found
 | 
					        if !found
 | 
				
			||||||
          " delete charactor
 | 
					          " delete charactor
 | 
				
			||||||
          let ms = s:matchend(text, '\v.')
 | 
					          let ms = s:matchend(before, '\v.')
 | 
				
			||||||
          if len(ms) == 0
 | 
					          if len(ms) == 0
 | 
				
			||||||
            break
 | 
					            break
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
          let i = i + 1
 | 
					          let before = ms[1]
 | 
				
			||||||
          let text = ms[1]
 | 
					          let bs = bs.s:backspace(ms[2])
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      endwhile
 | 
					      endwhile
 | 
				
			||||||
      let bs = repeat("\<BS>", i)
 | 
					      return bs.del.openPair.close.s:left(close)
 | 
				
			||||||
      if bs != ''
 | 
					 | 
				
			||||||
        call feedkeys(bs)
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
      call feedkeys(openPair.close.s:left(close), "n")
 | 
					 | 
				
			||||||
      return ""
 | 
					 | 
				
			||||||
      " return m.close.s:left(close)
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  endfor
 | 
					  endfor
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user