Open narnaud opened 1 week ago
@LeonMatthesKDAB What do you think? would it make sense?
API-wise this sounds good, although I don't know if there really is a need to rename Mark
to Cursor
.
Just removing TextRange and TextLocation is probably good enough.
Before refactoring this, we should also check how many TextRange and TextLocation instances are actually used in Knut. Mark and RangeMark have a slightly higher impact on performance, as they listen to all changes in a document and update their position. I doubt it will be an issue, but maybe we can benchmark some of our scripts to see whether there is a noticeable difference.
TextLocation
is only used by Code::references
, so no problem here.
`TextRange it's a bit more complex:
TextLocation
Symbols
: but symbols are invalidated when the document is changed...TextDocument
: selectRange, replace and deleteRange => we could use a RangeMark
CodeDocument
=> I think we could do without itCreation shouldn't be a problem in term of performances (there's a shared_ptr + a connect, but it's not really that big). I don't think updates will be noticeable either... we could try and benchmark.
This is related to #54 , we currently have 4 different classes to handle position in text:
int
: that's the general position in aTextDocument
TextRange
: simple classes with start/end positionTextLocation
: contains aTextRange
+ a documentCodeDocument::references
Mark
: position in a document, which is updated based on editsRangeMark
: as the name suggest, that's a range of 2 marks, for start/endTextRange
andTextLocation
, except for the auto updateI would like to reduce to 3 different classes:
int
: we keep this one for recording script, it's perfectCursor
: position in a document (exMark
)CursorRange
: range of cursor (exRangeMark
)Cursor is a better term and more explicit, and I don't think we need the non-document aware version: