From 190ff56e63431bd6bc715fb185b25b6f24a538e0 Mon Sep 17 00:00:00 2001 From: Tomohiro Oda Date: Thu, 9 May 2024 13:09:30 +0900 Subject: [PATCH] sort subdirectories in the same order as the file tree table so that the aPathForSpec will navigate the tree to the same location --- .../StDirectoryTreePresenter.class.st | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/NewTools-FileBrowser/StDirectoryTreePresenter.class.st b/src/NewTools-FileBrowser/StDirectoryTreePresenter.class.st index 129d93dd..fdf0cda5 100644 --- a/src/NewTools-FileBrowser/StDirectoryTreePresenter.class.st +++ b/src/NewTools-FileBrowser/StDirectoryTreePresenter.class.st @@ -40,24 +40,30 @@ StDirectoryTreePresenter >> defaultOutputPort [ ] { #category : 'accessing' } -StDirectoryTreePresenter >> expandPath: aFileLocator [ +StDirectoryTreePresenter >> expandPath: aFileLocator [ "Expand the receiver's tree to aFileLocator reference" - + | path aPathForSpec currentNode | - path := aFileLocator asPath segments asOrderedCollection. aPathForSpec := OrderedCollection new. aPathForSpec add: 1. - + currentNode := directoryTreePresenter roots anyOne. - - path do: [ :aPart | | found | - found := currentNode directories detect: [ :e | e basename = aPart ] ifNone: [ ^self ]. - aPathForSpec add: (currentNode directories indexOf: found). - currentNode := found ]. - directoryTreePresenter - selectPath: aPathForSpec scrollToSelection: false + path do: [ :aPart | + | subdirs | + subdirs := currentNode directories sorted: [ :a :b | + a basename caseInsensitiveLessOrEqual: b basename ]. + currentNode := nil. + subdirs doWithIndex: [ :subdir :index | + (currentNode isNil and: [ subdir basename = aPart ]) ifTrue: [ + currentNode := subdir. + aPathForSpec add: index ] ]. + currentNode ifNil: [ ^ self ] ]. + + directoryTreePresenter + selectPath: aPathForSpec + scrollToSelection: false ] { #category : 'initialization' }