Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix show the detail in lua table array part #280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions modules/dap/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,21 +677,46 @@ async def get_source(self, source: dap.Source) -> tuple[str, str|None]:
})
return body['content'], body.get('mimeType')

async def get_variables(self, variablesReference: int, without_names: bool = False) -> list[Variable]:
response = await self.request('variables', {
'variablesReference': variablesReference
})
async def get_variables(self, variablesReference: int, without_names: bool = False, indexedVariables: int|None = None, namedVariables: int|None = None) -> list[Variable]:
named_list = []
if namedVariables != None and namedVariables > 0:
response = await self.request('variables', {
'variablesReference': variablesReference,
'filter': 'named',
})

variables: list[dap.Variable] = response['variables']

# vscode seems to remove the names from variables in output events
if without_names:
for v in variables:
v.name = ''
v.value = v.value.split('\n')[0]

named_list = [Variable.from_variable(self, variablesReference, v) for v in variables]

indexed_list = []
if indexedVariables != None and indexedVariables > 0:
response = await self.request('variables', {
'variablesReference': variablesReference,
'filter': 'indexed',
'start': 0,
'count': indexedVariables,
})

variables: list[dap.Variable] = response['variables']

# vscode seems to remove the names from variables in output events
if without_names:
for v in variables:
v.name = ''
v.value = v.value.split('\n')[0]

variables: list[dap.Variable] = response['variables']
indexed_list = [Variable.from_variable(self, variablesReference, v) for v in variables]

# vscode seems to remove the names from variables in output events
if without_names:
for v in variables:
v.name = ''
v.value = v.value.split('\n')[0]
return named_list + indexed_list


return [Variable.from_variable(self, variablesReference, v) for v in variables]

def on_breakpoint_event(self, event: dap.BreakpointEvent):
assert event.breakpoint.id
Expand Down
11 changes: 9 additions & 2 deletions modules/dap/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def name(self) -> str:


class Variable:
def __init__(self, session: Session, name: str, value: str|None, variablesReference: int|None, containerVariablesReference: int|None = None, evaluateName: str|None = None, memoryReference: str|None = None) -> None:
def __init__(self, session: Session, name: str, value: str|None, variablesReference: int|None, containerVariablesReference: int|None = None, evaluateName: str|None = None, memoryReference: str|None = None,
indexedVariables: int|None = None, namedVariables: int|None = None) -> None:
self.session = session
self.name = name
self.evaluateName = evaluateName
Expand All @@ -44,6 +45,8 @@ def __init__(self, session: Session, name: str, value: str|None, variablesRefere
self.containerVariablesReference = containerVariablesReference
self.memoryReference = memoryReference
self.fetched: core.Future[list[Variable]]|None = None
self.indexedVariables = indexedVariables
self.namedVariables = namedVariables


@staticmethod
Expand All @@ -56,6 +59,8 @@ def from_variable(session: Session, containerVariablesReference: int, variable:
containerVariablesReference,
variable.evaluateName,
variable.memoryReference,
indexedVariables = variable.indexedVariables,
namedVariables = variable.namedVariables,
)

@staticmethod
Expand All @@ -74,11 +79,13 @@ def from_evaluate(session: Session, name: str, evaluate: dap.EvaluateResponse):
name,
evaluate.result,
evaluate.variablesReference,
indexedVariables = evaluate.indexedVariables,
namedVariables = evaluate.namedVariables,
)

async def fetch(self):
assert self.variablesReference
return await self.session.get_variables(self.variablesReference)
return await self.session.get_variables(self.variablesReference, indexedVariables = self.indexedVariables, namedVariables = self.namedVariables)

async def children(self) -> list[Variable]:
if not self.has_children:
Expand Down