mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[ai-completion] ML-4099 fix incorrect matching for multi-line comments in Python
GitOrigin-RevId: 5e6a9a56335ede2aac17af34d11e9f616e26d710
This commit is contained in:
committed by
intellij-monorepo-bot
parent
783e42f34c
commit
2e3c4937a3
@@ -26,9 +26,9 @@ object MultiLineVisitorUtils {
|
||||
}
|
||||
|
||||
private fun findEndOfMultiLineComment(start: Int, lines: List<LineInfo>, token: String): Int {
|
||||
val end = lines.asSequence().drop(start).indexOfFirst { it.text.contains(token) }
|
||||
if (end < 0) return lines.size
|
||||
return start + end
|
||||
val followingLines = lines.asSequence().drop(start + 1)
|
||||
val end = followingLines.indexOfFirst { it.text.contains(token) }
|
||||
return if (end < 0) lines.size else start + end
|
||||
}
|
||||
|
||||
private fun LanguageSupporter.getCommentRanges(lines: List<LineInfo>): List<Pair<Int, Int>> {
|
||||
@@ -47,7 +47,10 @@ object MultiLineVisitorUtils {
|
||||
if (line.startsWith(start)) {
|
||||
val match = findEndOfMultiLineComment(pos, lines, end)
|
||||
add(pos to match)
|
||||
assert(pos < match)
|
||||
assert(pos <= match) {
|
||||
"Multiline comment started at line ${pos} and ended at line ${match}:\n" +
|
||||
lines.subList(pos, match).joinToString("\n") { it.text }
|
||||
}
|
||||
pos = match + 1
|
||||
continue@outer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user