diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.ts index 3c469bc3b3a..ddbc257facf 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatCodeblockActions.ts @@ -264,13 +264,12 @@ export function registerChatCodeBlockActions() { // 1st sub-array - array with documents used to get the chat reply const docRefs: DocumentContextItem[][] = []; - const model = codeEditor.getModel(); - if (model) { + if (codeEditor.hasModel()) { + const model = codeEditor.getModel(); const currentDocUri = model.uri; const currentDocVersion = model.getVersionId(); const selections = codeEditor.getSelections(); - if (selections && selections.length > 0) { - + if (selections.length > 0) { docRefs.push([ { uri: currentDocUri,