From 6ebb350ec3ec4e3118964ac167a94ee888114dd2 Mon Sep 17 00:00:00 2001 From: tudnai Date: Fri, 11 Nov 2022 11:22:38 -0800 Subject: [PATCH] BugFix: Scroll on setting Breakpoint --- A2Mac/DebuggerViewController.swift | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/A2Mac/DebuggerViewController.swift b/A2Mac/DebuggerViewController.swift index 61610b9..3dda958 100644 --- a/A2Mac/DebuggerViewController.swift +++ b/A2Mac/DebuggerViewController.swift @@ -384,8 +384,7 @@ N V - B D I Z C // force regenerate disassembly disass_addr = 0xFFFF - DisplayDisassembly() -// scroll_to(view: Disass_Display, line: line) + DisplayDisassembly(scrollY: Disass_Display.visibleRect.origin.y) } else { highlightCursor(scrollView: Disass_Scroll, display: Disass_Display, mouseLocation: location) @@ -411,7 +410,7 @@ N V - B D I Z C } - func DisplayDisassembly() { + func DisplayDisassembly( scrollY : CGFloat = -1 ) { let m6502_saved = m6502 var disass = "" @@ -480,12 +479,18 @@ N V - B D I Z C if self.line_number_at_PC <= currentScrollLine || self.line_number_at_PC > currentScrollLine + 35 { self.scroll_to(view: self.Disass_Display, line: self.line_number_at_PC - 5) - // at the beginning it takes a while to fill up the buffer -- maybe allocation issue? - if currentScrollLine == 1 { - // so we need to scroll a bit later when the string is already populated -// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - self.scroll_to(view: self.Disass_Display, line: self.line_number_at_PC - 5) -// } + if scrollY < 0 { + // at the beginning it takes a while to fill up the buffer -- maybe allocation issue? + if currentScrollLine == 1 { + // so we need to scroll a bit later when the string is already populated + // DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + self.scroll_to(view: self.Disass_Display, line: self.line_number_at_PC - 5) + // } + } + } + else { + // caller wants a specific scroll location... + self.Disass_Display.scroll(NSPoint(x: 0, y: scrollY)) } } self.highlight(view: self.Disass_Display, line: self.line_number_at_PC, attr: self.lineAttrAtPC)