FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allowing a configurable initial max_depth for the Watch Window by Garethp · Pull Request #411 · vim-vdebug/vdebug · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .vim  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions plugin/vdebug.vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ let g:vdebug_options_defaults = {
\ 'debug_file' : '',
\ 'path_maps' : {},
\ 'watch_window_style' : 'expanded',
\ 'watch_window_initial_max_depth': 0,
\ 'marker_default' : '⬦',
\ 'marker_closed_tree' : '▸',
\ 'marker_open_tree' : '▾',
Expand Down
28 changes: 15 additions & 13 deletions python3/vdebug/ui/vimui.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@ def clear_eval_expression(self):
def write(self, msg, return_focus=True):
Window.write(self, msg, after="normal gg")

def accept_renderer(self, renderer):
self.clean()
self.write(renderer.render(0, opts.Options.get('watch_window_initial_max_depth', int)))


class StatusWindow(Window):

Expand Down Expand Up @@ -777,7 +781,7 @@ def __init__(self, response, title=None, contexts=None, current_context=0):
self.contexts = contexts if contexts is not None else {}
self.current_context = current_context

def render(self, indent=0):
def render(self, indent=0, max_depth=None):
res = self.__create_tabs()

if self.title:
Expand All @@ -787,14 +791,12 @@ def render(self, indent=0):
num_props = len(properties)
log.Log("Writing %i properties to the window" % num_props,
log.Logger.INFO)
for idx, prop in enumerate(properties):
final = False
try:
next_prop = properties[idx+1]
except IndexError:
final = True
next_prop = None
res += self.__render_property(prop, next_prop, final, indent)

depth_applied_properties = list(filter(lambda p: max_depth is None or p.depth <= max_depth, properties))
for idx, prop in enumerate(depth_applied_properties):
final = True if idx + 1 >= len(depth_applied_properties) else False
next_prop = None if final else depth_applied_properties[idx+1]
res += self.__render_property(prop, next_prop, final, indent, max_depth)

log.Log("Writing to window:\n"+res, log.Logger.DEBUG)

Expand All @@ -811,11 +813,11 @@ def __create_tabs(self):
return " ".join(res) + "\n\n"
return ""

def __render_property(self, p, next_p, last=False, indent=0):
def __render_property(self, p, next_p, last=False, indent=0, max_depth=None):
indent_str = "".rjust((p.depth * 2)+indent)
line = "%(indent)s %(marker)s %(name)s = (%(type)s)%(value)s" % {
'indent': indent_str,
'marker': self.__get_marker(p),
'marker': self.__get_marker(p, max_depth),
'name': p.display_name,
'type': p.type_and_size(),
'value': " " + p.value
Expand Down Expand Up @@ -847,10 +849,10 @@ def __render_property(self, p, next_p, last=False, indent=0):
line += "".rjust((depth * 2) - 1 + indent) + " /" + "\n"
return line

def __get_marker(self, property):
def __get_marker(self, property, max_depth=None):
char = opts.Options.get('marker_default')
if property.has_children:
if property.child_count() == 0:
if property.child_count() == 0 or (max_depth is not None and property.depth >= max_depth):
char = opts.Options.get('marker_closed_tree')
else:
char = opts.Options.get('marker_open_tree')
Expand Down

Back | FazBrowse Home | New Git URL