-
Notifications
You must be signed in to change notification settings - Fork 121
Fix inline text insertion handling in semantic token delta calculation #3707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
1c03de3
529b40d
61a2db0
b3da273
f154def
805fb88
a967801
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,8 +294,13 @@ private static List<SemanticTokensEdit> computeEdits(int[] prev, int[] curr) { | |
| * <p> | ||
| * При дельта-кодировании токены после точки вставки идентичны, | ||
| * кроме первого токена, у которого deltaLine смещён на lineOffset. | ||
| * При вставке текста без перевода строки (lineOffset == 0), первый токен | ||
| * может иметь смещённый deltaStart. | ||
| */ | ||
| private static int findSuffixMatchWithOffset(int[] prev, int[] curr, int firstDiffToken, int lineOffset, int tokenSize) { | ||
| final int DELTA_LINE_INDEX = 0; | ||
| final int DELTA_START_INDEX = 1; | ||
|
|
||
| int prevTokenCount = prev.length / tokenSize; | ||
| int currTokenCount = curr.length / tokenSize; | ||
|
|
||
|
|
@@ -310,9 +315,13 @@ private static int findSuffixMatchWithOffset(int[] prev, int[] curr, int firstDi | |
| int prevIdx = (prevTokenCount - 1 - i) * tokenSize; | ||
| int currIdx = (currTokenCount - 1 - i) * tokenSize; | ||
|
|
||
| // Сначала проверяем все поля кроме deltaLine | ||
| // Для граничного токена при inline-редактировании (lineOffset == 0) | ||
| // разрешаем различие в deltaStart | ||
| int firstFieldToCheck = (!foundBoundary && lineOffset == 0) ? DELTA_START_INDEX + 1 : DELTA_START_INDEX; | ||
|
|
||
| // Проверяем поля кроме deltaLine (и возможно deltaStart для граничного токена) | ||
| boolean otherFieldsMatch = true; | ||
| for (int j = 1; j < tokenSize; j++) { | ||
| for (int j = firstFieldToCheck; j < tokenSize; j++) { | ||
|
Comment on lines
+318
to
+324
|
||
| if (prev[prevIdx + j] != curr[currIdx + j]) { | ||
| otherFieldsMatch = false; | ||
| break; | ||
|
|
@@ -324,12 +333,20 @@ private static int findSuffixMatchWithOffset(int[] prev, int[] curr, int firstDi | |
| } | ||
|
|
||
| // Теперь проверяем deltaLine | ||
| int prevDeltaLine = prev[prevIdx]; | ||
| int currDeltaLine = curr[currIdx]; | ||
| int prevDeltaLine = prev[prevIdx + DELTA_LINE_INDEX]; | ||
| int currDeltaLine = curr[currIdx + DELTA_LINE_INDEX]; | ||
|
|
||
| if (prevDeltaLine == currDeltaLine) { | ||
| // Полное совпадение | ||
| // Полное совпадение (или совпадение с учётом deltaStart при inline-редактировании) | ||
| suffixMatch++; | ||
| // Если это был граничный токен при inline-редактировании, отмечаем его найденным | ||
| if (!foundBoundary && lineOffset == 0) { | ||
| int prevDeltaStart = prev[prevIdx + DELTA_START_INDEX]; | ||
| int currDeltaStart = curr[currIdx + DELTA_START_INDEX]; | ||
| if (prevDeltaStart != currDeltaStart) { | ||
| foundBoundary = true; | ||
| } | ||
| } | ||
| } else if (!foundBoundary && currDeltaLine - prevDeltaLine == lineOffset) { | ||
| // Граничный токен — deltaLine отличается ровно на lineOffset | ||
| suffixMatch++; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.