summaryrefslogtreecommitdiffstats
path: root/patches/source/vim/patches/7.4.397
blob: 4d70ca635a44e779343382bc066b1c18be637a4f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
To: vim_dev@googlegroups.com
Subject: Patch 7.4.397
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.4.397
Problem:    Matchparen only uses the topmost syntax item.
Solution:   Go through the syntax stack to find items. (James McCoy)
            Also use getcurpos() when possible.
Files:      runtime/plugin/matchparen.vim


*** ../vim-7.4.396/runtime/plugin/matchparen.vim	2014-06-17 17:48:21.772628007 +0200
--- runtime/plugin/matchparen.vim	2014-08-06 19:02:04.967128364 +0200
***************
*** 1,6 ****
  " Vim plugin for showing matching parens
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
! " Last Change: 2014 Jun 17
  
  " Exit quickly when:
  " - this plugin was already loaded (or disabled)
--- 1,6 ----
  " Vim plugin for showing matching parens
  " Maintainer:  Bram Moolenaar <Bram@vim.org>
! " Last Change: 2014 Jul 19
  
  " Exit quickly when:
  " - this plugin was already loaded (or disabled)
***************
*** 54,67 ****
    let c_col = col('.')
    let before = 0
  
!   let c = getline(c_lnum)[c_col - 1]
    let plist = split(&matchpairs, '.\zs[:,]')
    let i = index(plist, c)
    if i < 0
      " not found, in Insert mode try character before the cursor
      if c_col > 1 && (mode() == 'i' || mode() == 'R')
        let before = 1
!       let c = getline(c_lnum)[c_col - 2]
        let i = index(plist, c)
      endif
      if i < 0
--- 54,68 ----
    let c_col = col('.')
    let before = 0
  
!   let text = getline(c_lnum)
!   let c = text[c_col - 1]
    let plist = split(&matchpairs, '.\zs[:,]')
    let i = index(plist, c)
    if i < 0
      " not found, in Insert mode try character before the cursor
      if c_col > 1 && (mode() == 'i' || mode() == 'R')
        let before = 1
!       let c = text[c_col - 2]
        let i = index(plist, c)
      endif
      if i < 0
***************
*** 87,100 ****
    " Find the match.  When it was just before the cursor move it there for a
    " moment.
    if before > 0
!     let save_cursor = winsaveview()
      call cursor(c_lnum, c_col - before)
    endif
  
!   " When not in a string or comment ignore matches inside them.
    " We match "escape" for special items, such as lispEscapeSpecial.
!   let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .
! 	\ '=~?  "string\\|character\\|singlequote\\|escape\\|comment"'
    execute 'if' s_skip '| let s_skip = 0 | endif'
  
    " Limit the search to lines visible in the window.
--- 88,114 ----
    " Find the match.  When it was just before the cursor move it there for a
    " moment.
    if before > 0
!     let has_getcurpos = exists("*getcurpos")
!     if has_getcurpos
!       " getcurpos() is more efficient but doesn't exist before 7.4.313.
!       let save_cursor = getcurpos()
!     else
!       let save_cursor = winsaveview()
!     endif
      call cursor(c_lnum, c_col - before)
    endif
  
!   " Build an expression that detects whether the current cursor position is in
!   " certain syntax types (string, comment, etc.), for use as searchpairpos()'s
!   " skip argument.
    " We match "escape" for special items, such as lispEscapeSpecial.
!   let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' .
! 	\ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))'
!   " If executing the expression determines that the cursor is currently in
!   " one of the syntax types, then we want searchpairpos() to find the pair
!   " within those syntax types (i.e., not skip).  Otherwise, the cursor is
!   " outside of the syntax types and s_skip should keep its value so we skip any
!   " matching pair inside the syntax types.
    execute 'if' s_skip '| let s_skip = 0 | endif'
  
    " Limit the search to lines visible in the window.
***************
*** 147,153 ****
    endtry
  
    if before > 0
!     call winrestview(save_cursor)
    endif
  
    " If a match is found setup match highlighting.
--- 161,171 ----
    endtry
  
    if before > 0
!     if has_getcurpos
!       call setpos('.', save_cursor)
!     else
!       call winrestview(save_cursor)
!     endif
    endif
  
    " If a match is found setup match highlighting.
*** ../vim-7.4.396/src/version.c	2014-08-06 18:17:03.475147780 +0200
--- src/version.c	2014-08-06 19:06:44.627126354 +0200
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     397,
  /**/

-- 
Often you're less important than your furniture.  If you think about it, you
can get fired but your furniture stays behind, gainfully employed at the
company that didn't need _you_ anymore.
				(Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///