File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Sources/DiffableTextKit/Styles Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,14 @@ public struct PrefixTextStyle<Base: DiffableTextStyle>: WrapperTextStyle {
5959
6060 @inlinable func label( _ commit: inout Commit < Value > ) {
6161 guard !prefix. isEmpty else { return }
62- let selection = commit. snapshot. selection
63- let prefix = Snapshot ( prefix, as: . phantom)
62+ let base = commit. snapshot
6463
65- commit. snapshot = prefix + commit. snapshot
64+ commit. snapshot = Snapshot ( prefix, as: . phantom)
65+ let size = commit. snapshot. count /*-----------*/
66+ commit. snapshot. append ( contentsOf: /*---*/ base)
6667
67- guard let selection else { return }
68- let offsets = selection. map ( { prefix . count + $0. attribute } )
68+ guard let selection = base . selection else { return }
69+ let offsets = selection. map ( { size + $0. attribute } )
6970 let lower = commit. snapshot. index ( commit. snapshot. startIndex, offsetBy: offsets. lower)
7071 let upper = commit. snapshot. index ( lower/*-*/, offsetBy: offsets. upper - offsets. lower)
7172 commit. snapshot. select ( Range ( uncheckedBounds: ( lower, upper) ) )
You can’t perform that action at this time.
0 commit comments