Skip to content

Commit

Permalink
Merge branch 'main' into tl/add-support-link-for-cody-pro
Browse files Browse the repository at this point in the history
  • Loading branch information
toolmantim committed Mar 14, 2024
2 parents 0b6bea9 + 9a4a5e4 commit bc89f63
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 43 deletions.
32 changes: 16 additions & 16 deletions agent/recordings/enterpriseClient_3965582033/recording.har.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 19 additions & 12 deletions lib/shared/src/chat/transcript/display-text.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type * as vscode from 'vscode'
import type { URI } from 'vscode-uri'
import type { ContextItem } from '../../codebase-context/messages'
import type { RangeData } from '../../common/range'
import { type RangeData, toRangeData } from '../../common/range'
import { displayPath } from '../../editor/displayPath'
import { reformatBotMessageForChat } from '../viewHelpers'
import type { ChatMessage } from './messages'
Expand Down Expand Up @@ -41,17 +41,24 @@ function createDisplayTextWithFileLinks(humanInput: string, files: ContextItem[]
for (const file of files) {
// +1 on the end line numbers because we want to make sure to include everything on the end line by
// including the next line at position 0.
formattedText = replaceFileNameWithMarkdownLink(
formattedText,
file.uri,
file.range
? {
start: { line: file.range.start.line, character: 0 },
end: { line: file.range.end.line + 1, character: 0 },
}
: undefined,
file.type === 'symbol' ? file.symbolName : undefined
)
const range = file.range ? toRangeData(file.range) : undefined
try {
formattedText = replaceFileNameWithMarkdownLink(
formattedText,
file.uri,
range
? {
start: { line: range.start.line, character: 0 },
end: { line: range.end.line + 1, character: 0 },
}
: undefined,
file.type === 'symbol' ? file.symbolName : undefined
)
} catch (error) {
console.error('createDisplayTextWithFileLinks error:', error)
// Just use text without links as a fallback. This can happen on chat history that was
// serialized using an old and unrecognized format, which is a subtle bug.
}
}
return formattedText
}
Expand Down
6 changes: 6 additions & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a
- Autocomplete: Upgrade tree-sitter and expand language support. [pull/3373](https://github.com/sourcegraph/cody/pull/3373)
- Autocomplete: Do not cut off completions when they are almost identical to the following non-empty line. [pull/3377](https://github.com/sourcegraph/cody/pull/3377)

## [1.8.3]

### Fixed

- Fix crash upon initialization in the stable build if a prerelease version of the VS Code extension was used for chat after 2024-03-08. [pull/3394](https://github.com/sourcegraph/cody/pull/3394)

## [1.8.2]

### Added
Expand Down
2 changes: 1 addition & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cody-ai",
"private": true,
"displayName": "Cody AI",
"version": "1.8.2",
"version": "1.8.3",
"publisher": "sourcegraph",
"license": "Apache-2.0",
"icon": "resources/cody.png",
Expand Down
10 changes: 6 additions & 4 deletions vscode/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { defineConfig } from '@playwright/test'

const isWin = process.platform.startsWith('win')

export default defineConfig({
workers: 1,
// Give failing tests a second chance
retries: 2,
// Give failing tests more chances
retries: isWin ? 4 : 2,
testDir: 'test/e2e',
timeout: 20000,
timeout: isWin ? 30000 : 20000,
expect: {
timeout: 3000,
timeout: isWin ? 5000 : 3000,
},
})
1 change: 1 addition & 0 deletions vscode/src/completions/detect-multiline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const LANGUAGES_WITH_MULTILINE_SUPPORT = [
'java',
'javascript',
'javascriptreact',
'kotlin',
'php',
'python',
'rust',
Expand Down
Original file line number Diff line number Diff line change
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")
}"
`)
})
})
8 changes: 4 additions & 4 deletions vscode/src/editor/utils/document-sections.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as vscode from 'vscode'
import { IndentationBasedFoldingRangeProvider } from '../../lsp/foldingRanges'
const isIndentationBasedFoldingRanges =
vscode.workspace.getConfiguration().get<string>('cody.experimental.foldingRanges', 'lsp') ===
'indentation-based'

export async function getDocumentSections(
doc: vscode.TextDocument,
Expand Down Expand Up @@ -247,7 +244,10 @@ async function defaultGetFoldingRanges(uri: vscode.Uri): Promise<vscode.FoldingR
// setting `"cody.experimental.foldingRanges": "indentation-based"` and
// reload VS Code. Beyond feature parity between all clients, this implementation
// can be used to write test cases without mocking, which is a nice benefit.
if (isIndentationBasedFoldingRanges) {
if (
vscode.workspace.getConfiguration().get<string>('cody.experimental.foldingRanges', 'lsp') ===
'indentation-based'
) {
const provider = new IndentationBasedFoldingRangeProvider()
const document = await vscode.workspace.openTextDocument(uri)
return provider.provideFoldingRanges(document, {}, new vscode.CancellationTokenSource().token)
Expand Down
1 change: 1 addition & 0 deletions vscode/src/tree-sitter/language.ts
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion vscode/webviews/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineProjectWithDefaults(__dirname, {
target: 'esnext',
assetsDir: '.',
minify: false,
sourcemap: true,
sourcemap: false,
reportCompressedSize: false,
rollupOptions: {
watch: {
Expand Down

0 comments on commit bc89f63

Please sign in to comment.