forked from qt-creator/qt-creator
Clang: Fix dot-arrow-correction for not-yet-parsed unsaved content
The issue was re-producible with e.g.:
void g()
{
// Type 'foo.' as fast as possible in the next line
}
This led to "foo->" with completion results as if there was no "foo." at
all in that line.
We relied on a correct position for
translationUnit.sourceLocationAtWithoutReparsing(), but the just typed
characters were not yet reparsed. And we do not want to reparse at that
point since takes too long. We already determine the utf8 position for
the dot character, so simply use that instead.
This completes commit 17c1325cc4.
Change-Id: I669888b5c17ee63b2aec7b16c9921f9d79e281f9
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
@@ -71,15 +71,24 @@ const char *UnsavedFile::filePath() const
|
||||
return cxUnsavedFile.Filename;
|
||||
}
|
||||
|
||||
bool UnsavedFile::hasCharacterAt(uint line, uint column, char character) const
|
||||
uint UnsavedFile::toUtf8Position(uint line, uint column, bool *ok) const
|
||||
{
|
||||
Utf8PositionFromLineColumn converter(cxUnsavedFile.Contents);
|
||||
if (converter.find(line, column)) {
|
||||
const uint utf8Position = converter.position();
|
||||
return hasCharacterAt(utf8Position, character);
|
||||
*ok = true;
|
||||
return converter.position();
|
||||
}
|
||||
|
||||
return false;
|
||||
*ok = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool UnsavedFile::hasCharacterAt(uint line, uint column, char character) const
|
||||
{
|
||||
bool positionIsOk = false;
|
||||
const uint utf8Position = toUtf8Position(line, column, &positionIsOk);
|
||||
|
||||
return positionIsOk && hasCharacterAt(utf8Position, character);
|
||||
}
|
||||
|
||||
bool UnsavedFile::hasCharacterAt(uint position, char character) const
|
||||
|
||||
Reference in New Issue
Block a user