Skip to content

Commit e7fb282

Browse files
authored
Suggest diff editors in chat completions (#285543)
Fix #285510
1 parent fd54d38 commit e7fb282

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/vs/workbench/contrib/chat/browser/widget/input/editor/chatInputCompletions.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { INotificationService } from '../../../../../../../platform/notification
3838
import { Registry } from '../../../../../../../platform/registry/common/platform.js';
3939
import { IWorkspaceContextService } from '../../../../../../../platform/workspace/common/workspace.js';
4040
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from '../../../../../../common/contributions.js';
41-
import { EditorsOrder } from '../../../../../../common/editor.js';
41+
import { EditorsOrder, isDiffEditorInput } from '../../../../../../common/editor.js';
4242
import { IEditorService } from '../../../../../../services/editor/common/editorService.js';
4343
import { IHistoryService } from '../../../../../../services/history/common/history.js';
4444
import { LifecyclePhase } from '../../../../../../services/lifecycle/common/lifecycle.js';
@@ -974,21 +974,22 @@ class BuiltinDynamicCompletions extends Disposable {
974974
// HISTORY
975975
// always take the last N items
976976
for (const [i, item] of this.historyService.getHistory().entries()) {
977-
if (!item.resource || seen.has(item.resource) || !this.instantiationService.invokeFunction(accessor => isSupportedChatFileScheme(accessor, item.resource!.scheme))) {
977+
const resource = isDiffEditorInput(item) ? item.modified.resource : item.resource;
978+
if (!resource || seen.has(resource) || !this.instantiationService.invokeFunction(accessor => isSupportedChatFileScheme(accessor, resource.scheme))) {
978979
// ignore editors without a resource
979980
continue;
980981
}
981982

982983
if (pattern) {
983984
// use pattern if available
984-
const basename = this.labelService.getUriBasenameLabel(item.resource).toLowerCase();
985+
const basename = this.labelService.getUriBasenameLabel(resource).toLowerCase();
985986
if (!isPatternInWord(pattern, 0, pattern.length, basename, 0, basename.length)) {
986987
continue;
987988
}
988989
}
989990

990-
seen.add(item.resource);
991-
const newLen = result.suggestions.push(makeCompletionItem(item.resource, FileKind.FILE, i === 0 ? localize('activeFile', 'Active file') : undefined, i === 0));
991+
seen.add(resource);
992+
const newLen = result.suggestions.push(makeCompletionItem(resource, FileKind.FILE, i === 0 ? localize('activeFile', 'Active file') : undefined, i === 0));
992993
if (newLen - len >= 5) {
993994
break;
994995
}

0 commit comments

Comments
 (0)