Commit bc422b4
authored
Highlight Ignored Indexes (#114)
# Description
Tracks indexes that were not given an explicit color and highlights them
as normal text. This fixes problems where certain characters would
change color (eg: they were put in a comment) and then need to change
back, but were skipped.
This also fixes the problem in #99 where text was not given an explicit
highlight on paste. [Since `STTextView` does not add default attributes
to pasted text by
default](https://github.com/krzyzanowskim/STTextView/blob/5d137731401d12412d567244facf086c325ff95b/Sources/STTextView/STTextView%2BCopyPaste.swift#L26)
(see the `useTypingAttributes: false` in that method call).
Doing this also seems to have an effect on the annoying glitching that
was caused when entering text in an empty line (see the comment screen
recording)
This PR also adds a helper for converting from an `NSRange` to a
`Range<Int>` and gets rid of a bunch of ugly force unwraps that existed
before. It also adds some convenience methods for modifying `IndexSet`s
using indexes from `NSRange` objects.
# Related Issues
- #99
# UI Fixes
### Paste Text (Old)
https://user-images.githubusercontent.com/35942988/212186310-ee50dcaa-ebec-4e21-905b-562fc2cdf940.mov
### Paste Text (new)
https://user-images.githubusercontent.com/35942988/212186342-402ceb89-2122-4431-88ac-2363e6452323.mov
### Multi-Line comment (old)
https://user-images.githubusercontent.com/35942988/212186411-dc77744f-270b-4615-80c6-ed02e7c38e80.mov
### Multi-Line comment (new)
https://user-images.githubusercontent.com/35942988/212186437-ba014944-fa6c-4de9-8ad3-c8105a655418.mov
Closes #99File tree
2 files changed
+68
-21
lines changed- Sources/CodeEditTextView
- Extensions
- Highlighting
2 files changed
+68
-21
lines changedLines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 45 | + | |
49 | 46 | | |
50 | 47 | | |
51 | 48 | | |
| |||
107 | 104 | | |
108 | 105 | | |
109 | 106 | | |
110 | | - | |
| 107 | + | |
111 | 108 | | |
112 | 109 | | |
113 | 110 | | |
| |||
129 | 126 | | |
130 | 127 | | |
131 | 128 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | 129 | | |
139 | 130 | | |
140 | 131 | | |
| |||
161 | 152 | | |
162 | 153 | | |
163 | 154 | | |
164 | | - | |
165 | | - | |
166 | | - | |
| 155 | + | |
| 156 | + | |
167 | 157 | | |
168 | | - | |
| 158 | + | |
169 | 159 | | |
170 | 160 | | |
171 | 161 | | |
172 | 162 | | |
173 | | - | |
174 | | - | |
| 163 | + | |
| 164 | + | |
175 | 165 | | |
176 | 166 | | |
177 | | - | |
| 167 | + | |
178 | 168 | | |
179 | 169 | | |
180 | 170 | | |
181 | 171 | | |
182 | 172 | | |
183 | | - | |
| 173 | + | |
184 | 174 | | |
185 | 175 | | |
186 | 176 | | |
187 | 177 | | |
188 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
189 | 184 | | |
190 | 185 | | |
191 | 186 | | |
| |||
196 | 191 | | |
197 | 192 | | |
198 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
199 | 207 | | |
| 208 | + | |
200 | 209 | | |
201 | 210 | | |
202 | 211 | | |
| |||
227 | 236 | | |
228 | 237 | | |
229 | 238 | | |
230 | | - | |
| 239 | + | |
231 | 240 | | |
232 | 241 | | |
233 | 242 | | |
| |||
263 | 272 | | |
264 | 273 | | |
265 | 274 | | |
266 | | - | |
| 275 | + | |
267 | 276 | | |
268 | 277 | | |
269 | 278 | | |
| |||
0 commit comments