From 49962804ad4840ea33ca96fddbbef653829895ea Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Thu, 7 Nov 2024 19:43:46 +0000 Subject: [PATCH] Limit the number of variable children drawn Added a new setting 'max_variable_children' defaulting to 200. This is pretty lame, but could help with pathological cases like #889. Better options for the future: - allow on the ... to show "everything" - implement paging properly - also make the code less inefficient. --- python3/vimspector/settings.py | 1 + python3/vimspector/variables.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/python3/vimspector/settings.py b/python3/vimspector/settings.py index 26d6258b..50e44246 100644 --- a/python3/vimspector/settings.py +++ b/python3/vimspector/settings.py @@ -24,6 +24,7 @@ 'bottombar_height': 10, 'disassembly_height': 20, 'variables_display_mode': 'compact', # compact/full + 'max_variable_children': 200, # For ui_mode = 'horizontal': 'sidebar_width': 50, diff --git a/python3/vimspector/variables.py b/python3/vimspector/variables.py index 4aa9262d..b4f4a44b 100644 --- a/python3/vimspector/variables.py +++ b/python3/vimspector/variables.py @@ -683,7 +683,16 @@ def GetMemoryReference( self ): def _DrawVariables( self, view, variables, indent_len, is_short = False ): assert indent_len > 0 - for variable in variables: + max_variable_children = settings.Int( 'max_variable_children' ) + for idx, variable in enumerate(variables): + if idx >= max_variable_children: + utils.AppendToBuffer( + view.buf, + f"{indent}... {len(variables) - max_variable_children} more", + hl = 'WarningMsg' + ) + break + text = '' # We borrow 1 space of indent to draw the change marker indent = ' ' * ( indent_len - 1 )