Closed toshi0383 closed 7 years ago
I pushed a fix to master, would you mind taking a look whether it works for your codebase? The commit with changes
Edit: according to @jpsim, treating key.offset / length as byteOffset is correct, so my fix of using that as characterOffset even if it passes sounds like a wrong approach. Need to take a look at this again and see if there is anything there that we might be doing wrong, or is this sourcekitten bug and in that case fill a report for them
Yeah, this is likely a bug in SourceKitten, and likely the same issue as realm/SwiftLint#1006.
We're investigating the following re-implementation, but since that breaks other things we haven't fully determined the scope of this issue:
func lineAndCharacter(forByteOffset offset: Int) -> (line: Int, character: Int)? {
let characterOffset = location(fromByteOffset: offset)
return lineAndCharacter(forCharacterOffset: characterOffset)
}
And to reiterate from twitter, yes all offsets and lengths reported by SourceKit are in bytes.
ok I think the master is working now, I used the suggestion for translating the byteOffset, once sourcekitten solves the internal issue we can go back to using old function. @toshi0383 can you confirm current master works for you? I added test but just to be sure
Confirmed fix at master. 👍
Arguments
source: test/Sample.swift
template: test/autoequatable.swift.template
crash
Looks like it's inside SourceKitten. SwiftLint doesn't crash on same code. I don't know why.