mirror of
https://github.com/fadden/6502bench.git
synced 2026-04-20 04:16:47 +00:00
Expand goto dialog address resolution
The "goto" dialog (Ctrl+G) jumps to an offset, address, or label. If an address is specified, it is resolved relative to the first line of the current selection, so that if the same address appears multiple times we select the "best" one. This turned out to be too restrictive, because if the region was marked with "disallow outbound address resolution" we wouldn't look anywhere except the current region. While arguably correct, it was annoying to have to move the cursor before being able to jump to a unique address elsewhere in the file. Now, if the address lookup fails to identify an offset, we repeat it with "disallow outbound" flags ignored.
This commit is contained in:
@@ -865,8 +865,10 @@ namespace CommonUtil {
|
||||
/// </remarks>
|
||||
/// <param name="srcOffset">Offset of the address reference.</param>
|
||||
/// <param name="targetAddr">Address to look up.</param>
|
||||
/// <param name="alwaysAllowOutward">If true, allow outward searches even if in regions
|
||||
/// marked as isolated.</param>
|
||||
/// <returns>The file offset, or -1 if the address falls outside the file.</returns>
|
||||
public int AddressToOffset(int srcOffset, int targetAddr) {
|
||||
public int AddressToOffset(int srcOffset, int targetAddr, bool alwaysAllowOutward = false) {
|
||||
TreeNode startNode = OffsetToNode(srcOffset, mTopNode);
|
||||
|
||||
TreeNode ignoreNode = null;
|
||||
@@ -877,7 +879,7 @@ namespace CommonUtil {
|
||||
return offset;
|
||||
}
|
||||
|
||||
if (startNode.Region.DisallowOutward) {
|
||||
if (startNode.Region.DisallowOutward && !alwaysAllowOutward) {
|
||||
return -1; // can't look at parent or siblings of this node
|
||||
}
|
||||
|
||||
|
||||
@@ -171,6 +171,11 @@ namespace SourceGen.WpfGui {
|
||||
// initial offset so we stay within current segment if there are overlapping
|
||||
// address ranges.
|
||||
int offset = mProject.AddrMap.AddressToOffset(mInitialOffset, addr);
|
||||
if (offset < 0) {
|
||||
// Retry, ignoring region isolation. Otherwise, if the selection is in a
|
||||
// region that disallows outward resolution, you can't goto most addresses.
|
||||
offset = mProject.AddrMap.AddressToOffset(mInitialOffset, addr, true);
|
||||
}
|
||||
if (offset >= 0) {
|
||||
TargetOffset = offset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user