File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change @@ -139,11 +139,7 @@ extension LineTable {
139
139
return nil
140
140
}
141
141
let lineSlice = self [ line]
142
- guard utf16Column <= content. utf16. distance ( from: lineSlice. startIndex, to: lineSlice. endIndex) else {
143
- // Column out of range.
144
- return nil
145
- }
146
- return content. utf16. index ( lineSlice. startIndex, offsetBy: utf16Column)
142
+ return content. utf16. index ( lineSlice. startIndex, offsetBy: utf16Column, limitedBy: lineSlice. endIndex)
147
143
}
148
144
149
145
/// Returns UTF8 buffer offset of given logical position.
@@ -181,11 +177,10 @@ extension LineTable {
181
177
return nil
182
178
}
183
179
let lineSlice = self [ line]
184
- guard utf8Column < = content. utf8. distance ( from : lineSlice. startIndex, to : lineSlice. endIndex) else {
180
+ guard let targetIndex = content. utf8. index ( lineSlice. startIndex, offsetBy : utf8Column , limitedBy : lineSlice. endIndex) else {
185
181
// Column out of range
186
182
return nil
187
183
}
188
- let targetIndex = content. utf8. index ( lineSlice. startIndex, offsetBy: utf8Column)
189
184
return content. utf16. distance ( from: lineSlice. startIndex, to: targetIndex)
190
185
}
191
186
}
You can’t perform that action at this time.
0 commit comments