Skip to content
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

Port candidates to main #203815

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export class ChatMarkdownDecorationsRenderer {
@IKeybindingService private readonly keybindingService: IKeybindingService,
@ILabelService private readonly labelService: ILabelService,
@ILogService private readonly logService: ILogService
) {

}
) { }

convertParsedRequestToMarkdown(parsedRequest: IParsedChatRequest): string {
let result = '';
Expand All @@ -37,9 +35,9 @@ export class ChatMarkdownDecorationsRenderer {
} else {
const uri = part instanceof ChatRequestDynamicVariablePart && part.data.map(d => d.value).find((d): d is URI => d instanceof URI)
|| undefined;
const title = uri ? this.labelService.getUriLabel(uri, { relative: true }) : '';
const title = uri ? encodeURIComponent(this.labelService.getUriLabel(uri, { relative: true })) : '';

result += `[${part.text}](${variableRefUrl}${title})`;
result += `[${part.text}](${variableRefUrl}?${title})`;
}
}

Expand All @@ -51,7 +49,7 @@ export class ChatMarkdownDecorationsRenderer {
const href = a.getAttribute('data-href');
if (href) {
if (href.startsWith(variableRefUrl)) {
const title = href.slice(variableRefUrl.length);
const title = decodeURIComponent(href.slice(variableRefUrl.length + 1));
a.parentElement!.replaceChild(
this.renderResourceWidget(a.textContent!, title),
a);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeat
import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IProductService } from 'vs/platform/product/common/productService';
import { Registry } from 'vs/platform/registry/common/platform';
import { inputPlaceholderForeground } from 'vs/platform/theme/common/colorRegistry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
Expand Down Expand Up @@ -512,20 +511,13 @@ class BuiltinDynamicCompletions extends Disposable {
constructor(
@ILanguageFeaturesService private readonly languageFeaturesService: ILanguageFeaturesService,
@IChatWidgetService private readonly chatWidgetService: IChatWidgetService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IProductService private readonly productService: IProductService,
) {
super();

this._register(this.languageFeaturesService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
_debugDisplayName: 'chatDynamicCompletions',
triggerCharacters: [chatVariableLeader],
provideCompletionItems: async (model: ITextModel, position: Position, _context: CompletionContext, _token: CancellationToken) => {
const fileVariablesEnabled = this.configurationService.getValue('chat.experimental.fileVariables') ?? this.productService.quality !== 'stable';
if (!fileVariablesEnabled) {
return;
}

const widget = this.chatWidgetService.getWidgetByInputUri(model.uri);
if (!widget || !widget.supportsFileReferences) {
return null;
Expand Down