Skip to content

Commit

Permalink
Autocomplete: add kotlin multiline support (#3404)
Browse files Browse the repository at this point in the history
  • Loading branch information
valerybugakov committed Mar 14, 2024
1 parent b77f3b6 commit 9a4a5e4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions vscode/src/completions/detect-multiline.ts
Expand Up @@ -45,6 +45,7 @@ const LANGUAGES_WITH_MULTILINE_SUPPORT = [
'java',
'javascript',
'javascriptreact',
'kotlin',
'php',
'python',
'rust',
Expand Down
Expand Up @@ -5,7 +5,7 @@ import type { CompletionParameters } from '@sourcegraph/cody-shared'

import { completion } from '../test-helpers'

import { getInlineCompletionsInsertText, params } from './helpers'
import { getInlineCompletionsInsertText, getInlineCompletionsWithInlinedChunks, params } from './helpers'

describe('[getInlineCompletions] languages', () => {
it('works with python', async () => {
Expand Down Expand Up @@ -304,4 +304,41 @@ describe('[getInlineCompletions] languages', () => {
}"
`)
})

it('works with kotlin', async () => {
const requests: CompletionParameters[] = []
const result = await getInlineCompletionsWithInlinedChunks(
`fun main() {
for (i in 0..10) {
if (i % 2 == 0) {
█println(i)
} else if (i % 3 == 0) {
println("Multiple of 3: $i")
} else {
println("ODD $i")
}
}
for (i in 0..11) {
println("unrelated")
}
}█`,
{
languageId: 'kotlin',
onNetworkRequest(params) {
requests.push(params)
},
}
)

expect(requests).toBeMultiLine()
expect(result.items[0].insertText).toMatchInlineSnapshot(`
"println(i)
} else if (i % 3 == 0) {
println("Multiple of 3: $i")
} else {
println("ODD $i")
}"
`)
})
})
1 change: 1 addition & 0 deletions vscode/src/tree-sitter/language.ts
Expand Up @@ -16,6 +16,7 @@ export function getLanguageConfig(languageId: string): LanguageConfig | null {
case 'java':
case 'javascript':
case 'javascriptreact':
case 'kotlin':
case 'php':
case 'rust':
case 'svelte':
Expand Down

0 comments on commit 9a4a5e4

Please sign in to comment.