| Edit | Rename | Changes | History | Upload | Download | Back to Top |
Alan Knight--Good idea. Reverse search prior to the last snapshot is there already, it's called "Recover last changes". It only does one snapshot, though, and I've often wished for it to do N.
Steven Kelly--I've been making this change since VW 2.0 - when you choose "Recover last changes" it asks for (roughly) how many snapshots to look back, then shows a list of that many along with their dates and the position in the changes file. You choose one, and the changes since then are brought into the changes list. The code for 5i.3 is below.
Kernel.SourceFileManager class, utilities findComment: aString in: aStream "Return the position in the stream of the end of the last occurrence of aString (presumably a snapshot message)" | firstChar endPosition position count index lastEnd str fmt snapshots lastEnds | fmt := SourceFileFormat formatForStream: aStream. str := fmt createMarkerString: aString. snapshots := (Dialog request: 'How far back do you want to look' initialAnswer: '3') asNumber. snapshots isInteger ifFalse: [snapshots := 1]. firstChar := str first. aStream setToEnd. position := aStream position. lastEnds := SortedCollection new. lastEnd := nil. [endPosition := position. lastEnds size < snapshots and: [(position := endPosition - 5000 max: 0) < endPosition]] whileTrue: [aStream position: position. count := endPosition - position. [count > 0] whileTrue: [count := count - 1. aStream next = firstChar ifTrue: [index := 2. [index <= str size and: [(str at: index) = aStream next]] whileTrue: [index := index + 1]. index > str size ifTrue: [lastEnd := aStream position. lastEnds add: lastEnd->(aStream next; nextChunk). aStream position: lastEnd] ifFalse: [aStream position: endPosition - count]]]]. ^(Dialog choose: 'Which position?' fromList: (lastEnds collect: [:x | x printString]) values: lastEnds lines: 10 cancel: [lastEnds last]) key
| Edit | Rename | Changes | History | Upload | Download | Back to Top |