Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Version 3.3

Bug fixed: The string of EX command is set to be case sensitive, so it is more accurate when excuting the EX command.
  • Loading branch information...
commit 65f04da42e26446cec8261092f674299325ab0d5 1 parent d55b4db
Wenlong Che authored vim-scripts committed

Showing 1 changed file with 22 additions and 37 deletions. Show diff stats Hide diff stats

  1. 59  plugin/srcexpl.vim
59  plugin/srcexpl.vim
@@ -6,8 +6,8 @@
6 6
 "                 and 'quickfix'. It works like the context window in the 
7 7
 "                 Source Insight.
8 8
 " Author:         CHE Wenlong <chewenlong AT buaa.edu.cn>
9  
-" Version:        3.2
10  
-" Last Change:    August 28, 2008
  9
+" Version:        3.3
  10
+" Last Change:    September 16, 2008
11 11
 
12 12
 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
13 13
 
@@ -69,7 +69,7 @@
69 69
 " |~              |                                          |~               |
70 70
 " |~              |~                                         |~               |
71 71
 " |-__Tag_List__--|-demo.c-----------------------------------|--_NERD_tree_---|
72  
-" |Source Explorer V3.2                                                       |
  72
+" |Source Explorer V3.3                                                       |
73 73
 " |~                                                                          |
74 74
 " |~                                                                          |
75 75
 " |~                                                                          |
@@ -429,35 +429,6 @@ function! g:SrcExpl_GoBack()
429 429
 
430 430
 endfunction " }}}
431 431
 
432  
-" SrcExpl_FilterEXcmd() {{{
433  
-
434  
-" Filter the Ex command information
435  
-
436  
-function! <SID>SrcExpl_FilterEXcmd(raw)
437  
-
438  
-    let l:idx = 0
439  
-    let l:new = ""
440  
-
441  
-    " Get the EX symbol in order to jump
442  
-    while a:raw[l:idx] != ''
443  
-        " If the '*', '[' and ']' in the function definition,
444  
-        " then we add the '\' in front of it.
445  
-        if a:raw[l:idx] == '*'
446  
-            let l:new = l:new . '\' . '*'
447  
-        elseif a:raw[l:idx] == '['
448  
-            let l:new = l:new . '\' . '['
449  
-        elseif a:raw[l:idx] == ']'
450  
-            let l:new = l:new . '\' . ']'
451  
-        else
452  
-            let l:new = l:new . a:raw[l:idx]
453  
-        endif
454  
-        let l:idx += 1
455  
-    endwhile
456  
-
457  
-    return l:new
458  
-
459  
-endfunction " }}}
460  
-
461 432
 " SrcExpl_SelToJump() {{{
462 433
 
463 434
 " Select one of multi-definitions, and jump to there
@@ -467,6 +438,7 @@ function! <SID>SrcExpl_SelToJump()
467 438
     let l:index = 0
468 439
     let l:fname = ""
469 440
     let l:excmd = ""
  441
+    let l:expr  = ""
470 442
 
471 443
     " Must in the Source Explorer window
472 444
     if !&previewwindow
@@ -507,8 +479,14 @@ function! <SID>SrcExpl_SelToJump()
507 479
     silent! exe s:SrcExpl_editWin . "wincmd w"
508 480
     " Open the file of definition context
509 481
     exe "edit " . s:SrcExpl_tagsPath . l:fname
510  
-    " Use Ex Command to Jump to the exact position of the definition
511  
-    silent! exe <SID>SrcExpl_FilterEXcmd(l:excmd)
  482
+    " Modify the EX Command to locate the tag exactly
  483
+    let l:expr = substitute(l:excmd, '/^', '/^\\C', 'g')
  484
+    let l:expr = substitute(l:expr,  '\*',  '\\\*', 'g')
  485
+    let l:expr = substitute(l:expr,  '\[',  '\\\[', 'g')
  486
+    let l:expr = substitute(l:expr,  '\]',  '\\\]', 'g')
  487
+    " Use EX Command to Jump to the exact position of the definition
  488
+    silent! exe l:expr
  489
+    " Match the symbol
512 490
     call <SID>SrcExpl_MatchExpr()
513 491
 
514 492
 endfunction " }}}
@@ -587,7 +565,7 @@ function! <SID>SrcExpl_MatchExpr()
587 565
     " Match the symbol
588 566
     call search("$", "b")
589 567
     let s:SrcExpl_symbol = substitute(s:SrcExpl_symbol, 
590  
-        \ '\\', '\\\\', "")
  568
+        \ '\\', '\\\\', '')
591 569
     call search('\V\C\<' . s:SrcExpl_symbol . '\>')
592 570
 
593 571
 endfunction " }}}
@@ -759,14 +737,21 @@ endfunction " }}}
759 737
 
760 738
 function! <SID>SrcExpl_ViewOneDef(fname, excmd)
761 739
 
  740
+    let l:expr = ""
  741
+
762 742
     " Open the file first
763 743
     exe "silent " . "pedit " . a:fname
764 744
     " Go to the Source Explorer window
765 745
     silent! wincmd P
766 746
     " Indeed back to the preview window
767 747
     if &previewwindow
  748
+        " Modify the EX Command to locate the tag exactly
  749
+        let l:expr = substitute(a:excmd, '/^', '/^\\C', 'g')
  750
+        let l:expr = substitute(l:expr,  '\*',  '\\\*', 'g')
  751
+        let l:expr = substitute(l:expr,  '\[',  '\\\[', 'g')
  752
+        let l:expr = substitute(l:expr,  '\]',  '\\\]', 'g')
768 753
         " Execute EX command according to the parameter
769  
-        silent! exe <SID>SrcExpl_FilterEXcmd(a:excmd)
  754
+        silent! exe l:expr
770 755
         " Just avoid highlight
771 756
         " silent! /\<\>
772 757
         " Match the symbol
@@ -1059,7 +1044,7 @@ function! <SID>SrcExpl_OpenWin()
1059 1044
         " Goto the end of the buffer
1060 1045
         $
1061 1046
         " Display the version of the Source Explorer
1062  
-        put! ='Source Explorer V3.2'
  1047
+        put! ='Source Explorer V3.3'
1063 1048
         " Delete the extra trailing blank line
1064 1049
         $ d _
1065 1050
         " Make it no modifiable

0 notes on commit 65f04da

Please sign in to comment.
Something went wrong with that request. Please try again.