-
Notifications
You must be signed in to change notification settings - Fork 16
Use International Components for Unicode (ICU) to parse line breaks #51
base: master
Are you sure you want to change the base?
Conversation
|
||
} | ||
|
||
struct Line { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some documentation to Line
to make sure we can remember what each of the fields is for.
let last: Bool | ||
|
||
func contains(_ index: String.Index) -> Bool { | ||
if last { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document why this condition is here. I know there is a failing test case for it.
|
||
private var lineNumber: Int | ||
|
||
private var handleTrailingNewLine: Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document what handleTrailingNewLine
is really trying to do. Probably needs a better name too.
} | ||
|
||
mutating func next() -> Line? { | ||
guard cursor < text.endIndex else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This next
function is a mess.
/// - Parameter offset: The offset from the start of the TextDocument. | ||
/// - Returns: A new and valid Position. | ||
/// - Throws: WorkspaceError.positionNotFound if the offset is not within the bounds of the TextDocument. | ||
func position(for offset: Int) throws -> Position { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make more sense as a function on TextDocument
or as an initializer on Position
that takes a TextDocument
and offset? 🤔
return try! String(contentsOf: url) | ||
}() | ||
|
||
override func setUp() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete these since they are not used.
} | ||
|
||
func testLastLine() { | ||
for line in AnySequence({ LineIterator(self.simpleBar) }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do this for all of the documents and find a way to abstract it so that it is not so verbose.
I am trying to improve the robustness of the
selection(startAt:,length:)
andbyteOffset(at:)
which had a tendency to not be able to translate positions over time.These errors.