Skip to content

Commit c10aee1

Browse files
authored
checkpoints + edits fix: selecting in code block and checkpoint color (#257567)
checkpoints + edits fix: selecting in code block and checkpoint highlight
1 parent 168c3db commit c10aee1

File tree

4 files changed

+33
-13
lines changed

4 files changed

+33
-13
lines changed

build/lib/stylelint/vscode-known-variables.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"--vscode-chat-requestBorder",
5858
"--vscode-chat-requestBubbleBackground",
5959
"--vscode-chat-requestBubbleHoverBackground",
60+
"--vscode-chat-checkpointSeparator",
6061
"--vscode-chat-requestCodeBorder",
6162
"--vscode-chat-slashCommandBackground",
6263
"--vscode-chat-slashCommandForeground",

src/vs/workbench/contrib/chat/browser/chatListRenderer.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,21 +1289,36 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
12891289
if (this.configService.getValue<string>('chat.editRequests') === 'inline' && !this.disableEdits) {
12901290
markdownPart.domNode.classList.add('clickable');
12911291
markdownPart.addDisposable(dom.addDisposableListener(markdownPart.domNode, dom.EventType.CLICK, (e: MouseEvent) => {
1292-
if (this.viewModel?.editing?.id !== element.id) {
1293-
const selection = dom.getWindow(templateData.rowContainer).getSelection();
1294-
if (selection && !selection.isCollapsed && selection.toString().length > 0) {
1295-
return;
1296-
}
1292+
if (this.viewModel?.editing?.id === element.id) {
1293+
return;
1294+
}
1295+
1296+
// Don't handle clicks on links
1297+
const clickedElement = e.target as HTMLElement;
1298+
if (clickedElement.tagName === 'A') {
1299+
return;
1300+
}
12971301

1298-
const clickedElement = e.target as HTMLElement;
1299-
if (clickedElement.tagName === 'A') {
1302+
// Don't handle if there's a text selection in the window
1303+
const selection = dom.getWindow(templateData.rowContainer).getSelection();
1304+
if (selection && !selection.isCollapsed && selection.toString().length > 0) {
1305+
return;
1306+
}
1307+
1308+
// Don't handle if there's a selection in code block
1309+
const monacoEditor = dom.findParentWithClass(clickedElement, 'monaco-editor');
1310+
if (monacoEditor) {
1311+
const editorPart = Array.from(this.editorsInUse()).find(editor =>
1312+
editor.element.contains(monacoEditor));
1313+
1314+
if (editorPart?.editor.getSelection()?.isEmpty() === false) {
13001315
return;
13011316
}
1302-
1303-
e.preventDefault();
1304-
e.stopPropagation();
1305-
this._onDidClickRequest.fire(templateData);
13061317
}
1318+
1319+
e.preventDefault();
1320+
e.stopPropagation();
1321+
this._onDidClickRequest.fire(templateData);
13071322
}));
13081323
this._register(this.hoverService.setupManagedHover(getDefaultHoverDelegate('element'), markdownPart.domNode, localize('requestMarkdownPartTitle', "Click to Edit"), { trapFocus: true }));
13091324
}

src/vs/workbench/contrib/chat/browser/media/chat.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ have to be updated for changes to the rules above, or to support more deeply nes
20952095
position: relative;
20962096

20972097
.checkpoint-divider {
2098-
border-top: 1px dashed var(--vscode-editorWidget-border);
2098+
border-top: 1px dashed var(--vscode-chat-checkpointSeparator);
20992099
margin: 15px 0;
21002100
width: 100%;
21012101
height: 0;
@@ -2111,7 +2111,7 @@ have to be updated for changes to the rules above, or to support more deeply nes
21112111

21122112
.codicon-container .codicon {
21132113
font-size: 14px;
2114-
color: var(--vscode-editorWidget-border);
2114+
color: var(--vscode-chat-checkpointSeparator);
21152115
}
21162116

21172117
.monaco-toolbar {

src/vs/workbench/contrib/chat/common/chatColors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export const chatRequestBubbleBackground = registerColor('chat.requestBubbleBack
6060

6161
export const chatRequestBubbleHoverBackground = registerColor('chat.requestBubbleHoverBackground', { dark: editorSelectionBackground, light: editorSelectionBackground, hcDark: null, hcLight: null }, localize('chat.requestBubbleHoverBackground', 'Background color of the chat request bubble on hover.'), true);
6262

63+
export const chatCheckpointSeparator = registerColor('chat.checkpointSeparator',
64+
{ dark: '#585858', light: '#a9a9a9', hcDark: '#a9a9a9', hcLight: '#a5a5a5' },
65+
localize('chatCheckpointSeparator', "Chat checkpoint separator color."));
66+
6367
export const chatLinesAddedForeground = registerColor(
6468
'chat.linesAddedForeground',
6569
{ dark: '#54B054', light: '#107C10', hcDark: '#54B054', hcLight: '#107C10' },

0 commit comments

Comments
 (0)