mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
LanguageServers/Cpp: Find the right token under the cursor
When the cursor is immediately to the right of a token, the cursor's column will be token.end.column + 1, so take this into account when choosing which token to autocomplete.
This commit is contained in:
parent
d28127c807
commit
18739ba87e
1 changed files with 3 additions and 1 deletions
|
@ -64,9 +64,11 @@ Optional<size_t> AutoComplete::token_in_position(const Vector<Cpp::Token>& token
|
||||||
{
|
{
|
||||||
for (size_t token_index = 0; token_index < tokens.size(); ++token_index) {
|
for (size_t token_index = 0; token_index < tokens.size(); ++token_index) {
|
||||||
auto& token = tokens[token_index];
|
auto& token = tokens[token_index];
|
||||||
|
if (token.m_start.line != token.m_end.line)
|
||||||
|
continue;
|
||||||
if (token.m_start.line != position.line())
|
if (token.m_start.line != position.line())
|
||||||
continue;
|
continue;
|
||||||
if (token.m_start.column > position.column() || token.m_end.column < position.column())
|
if (token.m_start.column + 1 > position.column() || token.m_end.column + 1 < position.column())
|
||||||
continue;
|
continue;
|
||||||
return token_index;
|
return token_index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue