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 {
139139 return nil
140140 }
141141 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)
147143 }
148144
149145 /// Returns UTF8 buffer offset of given logical position.
@@ -181,11 +177,10 @@ extension LineTable {
181177 return nil
182178 }
183179 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 {
185181 // Column out of range
186182 return nil
187183 }
188- let targetIndex = content. utf8. index ( lineSlice. startIndex, offsetBy: utf8Column)
189184 return content. utf16. distance ( from: lineSlice. startIndex, to: targetIndex)
190185 }
191186}
You can’t perform that action at this time.
0 commit comments