# HG changeset patch # User Claus Gittinger # Date 1559024882 -7200 # Node ID 65046835495689a3b5230f2aa9bcad1a19123faa # Parent d86e171efa4c2e10e38f50a1269bb471d70ed4ef #DOCUMENTATION by cg class: DirectoryView comment/format in: #readMonitoringDirectory diff -r d86e171efa4c -r 650468354956 DirectoryView.st --- a/DirectoryView.st Tue May 28 03:26:41 2019 +0000 +++ b/DirectoryView.st Tue May 28 08:28:02 2019 +0200 @@ -497,6 +497,7 @@ readMonitoringDirectory + "this is a very ugly piece of code - left in as a bad example of how to make ST look slow... DO NOT USE IT, but read to learn" @@ -524,6 +525,8 @@ listOfFiles := self listOfFiles. oldListOfFiles := listOfFiles copy. + "/ why sort, if you make a set anyway ? + "/ why make it a set - its the filenames of a folder anyway (no duplicates possible) (currentFilenames asSortedCollection: [:f1 :f2| f1 baseName < f2 baseName]) asSet do: [:fileName| (oldListOfFiles contains:[:fileRow | fileRow fileName = fileName ]) @@ -531,16 +534,20 @@ |nearestFileRow newRow r| newRow := FileRow new fileName: fileName asFilename. - "/ cg: how stupid is that? + "/ how stupid is that? nearestFileRow := listOfFiles indexOf: (listOfFiles detect: [:fileRow| fileRow baseName > fileName baseName] ifNone: nil). "/ nearestFileRow := listOfFiles findFirst:[:fileRow | fileRow baseName > fileName baseName]. nearestFileRow = 0 ifTrue: [listOfFiles add: newRow] ifFalse: [listOfFiles add: newRow beforeIndex: nearestFileRow]. + "/ r is uninitialized - therefore selection is lost monitoring ifTrue: [self selectionOfFile value: r]. ] ]. + "/ modifying while iterating; + "/ programmer found that it makes trouble and therefore did it in reverse order + "/ (which works, but only by chance) listOfFiles reverseDo: [:fileRow| (currentFilenames includes: fileRow fileName) @@ -556,6 +563,7 @@ ] "Modified: / 19-11-2016 / 20:34:14 / cg" + "Modified (format): / 28-05-2019 / 07:26:43 / Claus Gittinger" ! ! !DirectoryView methodsFor:'selection'!