@@ -81,9 +81,10 @@ def _UpdateView( self, breakpoint_list, show=True ):
8181 'toggle' : 'ToggleBreakpointViewBreakpoint' ,
8282 'toggle_all' : 'ToggleAllBreakpointsViewBreakpoint' ,
8383 'delete' : 'DeleteBreakpointViewBreakpoint' ,
84+ 'edit' : 'EditBreakpointOptionsViewBreakpoint' ,
8485 'jump_to' : 'JumpToBreakpointViewBreakpoint' ,
8586 'add_line' : 'SetAdvancedLineBreakpoint' ,
86- 'add_func' : 'AddAdvancedFunctionBreakpoint'
87+ 'add_func' : 'AddAdvancedFunctionBreakpoint' ,
8788 }
8889 for key , func in groups .items ():
8990 for mapping in utils .GetVimList ( mappings , key ):
@@ -100,27 +101,7 @@ def _UpdateView( self, breakpoint_list, show=True ):
100101
101102 utils .SetSyntax ( '' , 'vimspector-breakpoints' , self ._buffer )
102103
103- if utils .UseWinBar ():
104- vim .command ( 'nnoremenu <silent> 1.1 WinBar.Delete '
105- ':call vimspector#DeleteBreakpointViewBreakpoint()<CR>' )
106- vim .command ( 'nnoremenu <silent> 1.2 WinBar.Toggle '
107- ':call vimspector#ToggleBreakpointViewBreakpoint()<CR>' )
108- vim .command ( 'nnoremenu <silent> 1.2 WinBar.*Toggle '
109- ':call'
110- ' vimspector#ToggleAllBreakpointsViewBreakpoint()<CR>' )
111- vim .command ( 'nnoremenu <silent> 1.3 WinBar.Jump\\ To '
112- ':call vimspector#JumpToBreakpointViewBreakpoint()<CR>' )
113- # TODO: Add tests for this function
114- vim .command ( 'nnoremenu <silent> 1.4 WinBar.+Line '
115- ':call vimspector#SetAdvancedLineBreakpoint()<CR>' )
116- vim .command ( 'nnoremenu <silent> 1.4 WinBar.+Function '
117- ':call vimspector#AddAdvancedFunctionBreakpoint()<CR>' )
118- vim .command ( 'nnoremenu <silent> 1.4 WinBar.Clear '
119- ':call vimspector#ClearBreakpoints()<CR>' )
120- vim .command ( 'nnoremenu <silent> 1.4 WinBar.Save '
121- ':call vimspector#WriteSessionFile()<CR>' )
122- vim .command ( 'nnoremenu <silent> 1.4 WinBar.Load '
123- ':call vimspector#ReadSessionFile()<CR>' )
104+ self ._RenderWinBar ()
124105
125106 # we want to maintain the height of the window
126107 self ._win .options [ "winfixheight" ] = True
@@ -141,6 +122,28 @@ def FormatEntry( el ):
141122 utils .SetBufferContents ( self ._buffer ,
142123 list ( map ( FormatEntry , breakpoint_list ) ) )
143124
125+
126+ def _RenderWinBar ( self ):
127+ if not utils .UseWinBar ():
128+ return
129+
130+ if not self ._HasWindow ():
131+ return
132+
133+ with utils .LetCurrentWindow ( self ._win ):
134+ utils .SetWinBar (
135+ ( 'Del' , 'vimspector#DeleteBreakpointViewBreakpoint()' ),
136+ ( 'On/Off' , 'vimspector#ToggleBreakpointViewBreakpoint()' ),
137+ ( 'Edit' , 'vimspector#EditBreakpointOptionsViewBreakpoint()' ),
138+ ( '+Line' , 'vimspector#SetAdvancedLineBreakpoint()' ),
139+ ( '+Func' , 'vimspector#AddAdvancedFunctionBreakpoint()' ),
140+ ( 'Clr All' , 'vimspector#ClearBreakpoints()' ),
141+ ( 'Clr Excp' , 'vimspector#ResetExceptionBreakpoints()' ),
142+ ( 'Save' , 'vimspector#WriteSessionFile()' ),
143+ ( 'Load' , 'vimspector#ReadSessionFile()' ),
144+ )
145+
146+
144147 def CloseBreakpoints ( self ):
145148 if not self ._HasWindow ():
146149 return
@@ -336,6 +339,26 @@ def JumpToBreakpointViewBreakpoint( self ):
336339
337340 _JumpToBreakpoint ( bp )
338341
342+ def EditBreakpointOptionsViewBreakpoint ( self ):
343+ vbp = self ._breakpoints_view .GetBreakpointForLine ()
344+ if not vbp :
345+ return
346+
347+ # Try to find the actual breakpoint
348+ bp , index = self ._FindLineBreakpoint ( vbp .get ( 'filename' ),
349+ vbp .get ( 'lnum' ) )
350+
351+ if not bp :
352+ return
353+
354+ options = GetAdvancedBreakpointOptions ( bp [ 'options' ] )
355+ if options is None :
356+ return
357+
358+ self .SetLineBreakpoint ( vbp [ 'filename' ], vbp [ 'lnum' ], options )
359+ utils .UserMessage ( "Breakpoint updated." )
360+
361+
339362 def JumpToNextBreakpoint ( self , reverse = False ):
340363 bps = self ._breakpoints_view ._breakpoint_list
341364 if not bps :
@@ -440,6 +463,12 @@ def ClearBreakpoints( self ):
440463 self .UpdateUI ()
441464
442465
466+ def ResetExceptionBreakpoints ( self ):
467+ # TODO: Should exceptoni breakpoints be per-session!?
468+ self ._exception_breakpoints = None
469+ self .UpdateUI ()
470+
471+
443472 def _FindLineBreakpoint ( self , file_name , line ):
444473 for bp , index in self ._AllBreakpointsOnLine ( file_name , line ):
445474 return bp , index
@@ -1172,3 +1201,27 @@ def _SignToLine( self, file_name, bp ):
11721201 bp [ 'line' ] = int ( signs [ 0 ][ 'signs' ][ 0 ][ 'lnum' ] )
11731202
11741203 return
1204+
1205+
1206+ _extended_breakpoint_properties = [
1207+ { 'prop' : 'condition' , 'msg' : 'Enter condition expression' },
1208+ { 'prop' : 'hitCondition' , 'msg' : 'Enter hit count expression' },
1209+ { 'prop' : 'logMessage' ,
1210+ 'msg' : 'Enter log expression (to make log point)' },
1211+ ]
1212+
1213+
1214+ def GetAdvancedBreakpointOptions ( existing_options = None ):
1215+ options = {}
1216+ if existing_options :
1217+ options .update ( existing_options )
1218+
1219+ for spec in _extended_breakpoint_properties :
1220+ response = utils .AskForInput ( spec [ 'msg' ] + ': ' ,
1221+ options .get ( spec [ 'prop' ] ) )
1222+ if response is None :
1223+ return None
1224+ elif response :
1225+ options [ spec [ 'prop' ] ] = response
1226+
1227+ return options
0 commit comments