From d4b97007df59aa393cbd7b29335b682fe0e2b377 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 23 Jan 2020 11:13:37 -0800 Subject: [PATCH] Fix double-click jump to local var with annotation Double-clicking the opcode of an instruction that references a local variable (e.g. "LDA ]foo") moves the selection to the line that declares the variable. This wasn't working in the case where the local var was annotated (e.g. "LDA ]foo?"). --- SourceGen/MainController.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/SourceGen/MainController.cs b/SourceGen/MainController.cs index a6dd729..f3ea691 100644 --- a/SourceGen/MainController.cs +++ b/SourceGen/MainController.cs @@ -2713,6 +2713,16 @@ namespace SourceGen { return; } + // Find the actual symbol definition. + LocalVariableTable lvTable = mProject.LvTables[varOffset]; + DefSymbol foundSym = lvTable.GetByLabel(symRef.Label); + if (foundSym == null) { + // shouldn't be possible + Debug.WriteLine("Did not find " + symRef.Label + " in expected table"); + Debug.Assert(false); + return; + } + // We have the offset to which the local variable table is bound. We need to // walk down until we find the variable definitions, and find the line with the // matching symbol. @@ -2720,7 +2730,10 @@ namespace SourceGen { // We're comparing to the formatted strings -- safer than trying to find the symbol // in the table and then guess at how the table arranges itself for display -- so we // need to compare the formatted form of the label. - string cmpStr = mFormatter.FormatVariableLabel(symRef.Label); + // + // We need to use GenerateDisplayLabel() because the symbol might have an annotation. + string cmpStr = mFormatter.FormatVariableLabel( + foundSym.GenerateDisplayLabel(mFormatter)); int lineIndex = CodeLineList.FindLineIndexByOffset(varOffset); while (lineIndex < mProject.FileDataLength) { LineListGen.Line line = CodeLineList[lineIndex];