@@ -64,6 +64,12 @@ let s:save_cpo = &cpoptions
6464set cpoptions &vim
6565" }}}
6666"
67+
68+ " "
69+ " Available modes - to be used with the debugFunctionWrapper method
70+ " @setting debugging_modes
71+ "
72+ "
6773let s: modes = {
6874 \ ' std_debug' : 0 ,
6975 \ ' var_debug' : 1 ,
@@ -75,10 +81,14 @@ let g:debugStringCounterStep = 1
7581
7682" By default debugging lines should be of the form <directive_to_print> " <prefix_string><debug_number>
7783function ! g: DebugstringPrefixStr ()
78- let l: debug_str =
79- \ ' [' . fnamemodify (bufname (' %' ), ' :t' ) .
80- \ ' :' . getcurpos ()[1 ] .
81- \ ' ] DEBUGGING STRING ==> '
84+ let l: debug_str = ' [' . fnamemodify (bufname (' %' ), ' :t' ) . ' :'
85+ if getline (' .' ) = ~# " ^$" " Empty line
86+ let l: debug_str .= getcurpos ()[1 ]
87+ else
88+ let l: debug_str .= string (str2nr (getcurpos ()[1 ]) + 1 )
89+ endif
90+ let l: debug_str .= ' ] DEBUGGING STRING ==> '
91+
8292 return l: debug_str
8393endfunc
8494
@@ -122,7 +132,14 @@ let g:debugstringAlwaysIncludeHeader = 0 " Include Header in place?
122132" Wrapper around the low-level debug* methods.
123133" It also takes care of incrementing the g:debugCounter
124134"
125- function ! s: debugFunctionWrapper (mode )
135+ " {mode} refers to the type of debugging that is to be done. See
136+ " @setting(debugging_modes) for the available modes
137+ "
138+ " If an additional argument is provided it will be used as the expression - This
139+ " additional argument implies that the debugging mode is 'var_debug'
140+ "
141+ "
142+ function ! s: debugFunctionWrapper (mode , ... )
126143 let l: prev_pos = getcurpos ()
127144
128145 let l: append_at_same_line = 0
@@ -137,21 +154,32 @@ function! s:debugFunctionWrapper(mode)
137154 endif
138155
139156 AddDebugString
157+ call repeat#set (" \<Plug> DumpDebugString" )
140158
141159 elseif a: mode == # s: modes [' var_debug' ]
142160 if ! exists (' :AddDebugStringExpr' )
143161 echoerr " Command AddDebugStringExpr isn't implemented for filetype \" " . &filetype . " \" "
144162 return 0
145163 endif
146- let l: expr = input (" Input Expression: " )
164+ let l: expr = " "
165+ if len (a: 000 ) == # 0
166+ let l: expr = input (" Input Expression: " )
167+ else
168+ let l: expr = a: 1
169+ endif
170+
147171 AddDebugStringExpr (l: expr )
172+
173+ " Make way for repeat.vim
174+ execute ' nnoremap <silent> <Plug>DumpDebugStringSpecExpr :<C-U> :call <SID>debugFunctionWrapper(1, "' . l: expr . ' ")<CR>'
175+ call repeat#set (" \<Plug> DumpDebugStringSpecExpr" )
148176 else
149177 echoerr ' s:debugFunctionWrapper - Unknown mode: ' a: mode
150178 return 0
151179 endif
152180
153181 " correct indentation level
154- " normal ==
182+ normal ==
155183
156184 call s: incrDebugCounter () " increase the counter
157185
0 commit comments