Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/completions/common/config.ts
13399 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
/** How to determine where to terminate the completion to the current block. */
7
export enum BlockMode {
8
/**
9
* Parse the context + completion on the client using treesitter to
10
* determine blocks.
11
*/
12
Parsing = 'parsing',
13
/**
14
* Let the server parse out blocks and assume that the completion terminates
15
* at the end of a block.
16
*/
17
Server = 'server',
18
/**
19
* Runs both the treesitter parsing on the client plus indentation-based
20
* truncation on the proxy.
21
*/
22
ParsingAndServer = 'parsingandserver',
23
/**
24
* Client-based heuristic to display more multiline completions.
25
* It almost always requests a multiline completion from the server and tries to break it up to something useful on the client.
26
*
27
* This should not be rolled out at the moment (latency impact is high, UX needs further fine-tuning),
28
* but can be used for internal experimentation.
29
*/
30
MoreMultiline = 'moremultiline',
31
}
32
33
export function shouldDoParsingTrimming(blockMode: BlockMode): boolean {
34
return [BlockMode.Parsing, BlockMode.ParsingAndServer, BlockMode.MoreMultiline].includes(blockMode);
35
}
36
37
export function shouldDoServerTrimming(blockMode: BlockMode): boolean {
38
return [BlockMode.Server, BlockMode.ParsingAndServer].includes(blockMode);
39
}
40
41