From d5299d9d0a36f0a776ee04a87eb3962df5353db0 Mon Sep 17 00:00:00 2001 From: xulihang Date: Tue, 16 Feb 2021 15:05:29 +0800 Subject: [PATCH] scroll to 0 if another file is opened --- BasicCAT/BasicCAT.b4j | 11 +++++++---- BasicCAT/BasicCAT.b4j.meta | 4 ++-- BasicCAT/Project.bas | 7 ++++--- BasicCAT/searchAndReplaceDialog.bas | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/BasicCAT/BasicCAT.b4j b/BasicCAT/BasicCAT.b4j index 4d63f84..760f3e7 100644 --- a/BasicCAT/BasicCAT.b4j +++ b/BasicCAT/BasicCAT.b4j @@ -751,10 +751,13 @@ Sub MenuBar1_Action End Sub Sub ScrollTo(index As Int) - editorLV.ScrollTo(Max(0,index-1)) - If Abs(currentProject.lastEntry-index)>20 Then - Sleep(500) + If editorLV.Items.Size<>0 Then editorLV.ScrollTo(Max(0,index-1)) + If Abs(currentProject.lastEntry-index)>20 Then + Log("long range") + Sleep(500) + editorLV.ScrollTo(Max(0,index-1)) + End If End If End Sub @@ -1841,7 +1844,7 @@ Sub searchTableView_Action Dim lbl As Label=searchTableView.SelectedRowValues(0) Dim index As Int index=lbl.Text - editorLV.ScrollTo(index) + ScrollTo(index) End If End Select End Sub diff --git a/BasicCAT/BasicCAT.b4j.meta b/BasicCAT/BasicCAT.b4j.meta index ca9fc08..2b490b9 100644 --- a/BasicCAT/BasicCAT.b4j.meta +++ b/BasicCAT/BasicCAT.b4j.meta @@ -244,6 +244,6 @@ ModuleClosedNodes8= ModuleClosedNodes80= ModuleClosedNodes81= ModuleClosedNodes9= -NavigationStack=Project,targetTextArea_FocusChanged,1705,5,Project,Class_Globals,20,0,progressDialog,update2,36,0,Project,addTextAreaToSegmentPane,1330,0,Project,targetTextArea_KeyPressed,1626,6,Project,changeSegment,1640,6,Main,MenuBar1_Action,344,0,Main,editSource,487,0,Main,fillWithTMOrMT,700,0,Project,mi_Action,1470,0,Project,openFile,253,3 +NavigationStack=Project,mi_Action,1470,0,Project,closeFile,270,0,Main,changeNeglectedStatus,944,0,searchAndReplaceDialog,resultListView_Action,551,0,FontPicker,Initialize,22,0,Project,changeSegment,1662,0,Main,searchTableView_Action,1553,0,Main,MenuBar1_Action,344,0,Main,ScrollTo,469,6,Project,openFile,263,5 SelectedBuild=0 -VisibleModules=1,2,3,4,5,6,7,8,9,10,23,36 +VisibleModules=1,2,3,4,5,6,7,8,9,10,23,36,19,75 diff --git a/BasicCAT/Project.bas b/BasicCAT/Project.bas index b5b8dbf..dc74d95 100644 --- a/BasicCAT/Project.bas +++ b/BasicCAT/Project.bas @@ -252,15 +252,16 @@ Sub openFile(filename As String,onOpeningProject As Boolean) readWorkFile(currentFilename,segments,True,path) allsegments.AddAll(segments) Log("currentFilename:"¤tFilename) - If lastFilename=currentFilename And segments.Size<>0 Then - Log("ddd"&True) - Log(lastEntry) + If lastFilename=currentFilename Then Try Main.ScrollTo(lastEntry) Catch lastEntry=0 Log(LastException) End Try + Else + lastEntry=0 + Main.ScrollTo(lastEntry) End If Dim visibleRange As Range visibleRange=Main.getVisibleRange(Main.editorLV) diff --git a/BasicCAT/searchAndReplaceDialog.bas b/BasicCAT/searchAndReplaceDialog.bas index af24914..c925335 100644 --- a/BasicCAT/searchAndReplaceDialog.bas +++ b/BasicCAT/searchAndReplaceDialog.bas @@ -574,7 +574,7 @@ Sub resultListView_Action If filename<>Main.currentProject.currentFilename Then Main.currentProject.openFile(filename,False) End If - Main.editorLV.ScrollTo(tagMap.get("index")) + Main.ScrollTo(tagMap.get("index")) Main.MainForm.AlwaysOnTop=True Main.MainForm.AlwaysOnTop=False End Select