Skip to content

Commit

Permalink
Merge pull request #748 from tomooda/747-Bookmarks-in-StFileSystemPre…
Browse files Browse the repository at this point in the history
…senter-navigate-to-wrong-locations

sort subdirectories in the same order as the file tree table
  • Loading branch information
jecisc authored May 16, 2024
2 parents c711130 + 190ff56 commit 4abf002
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/NewTools-FileBrowser/StDirectoryTreePresenter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down

0 comments on commit 4abf002

Please sign in to comment.