@@ -11,7 +11,7 @@ import { getTabSizeSetting } from '../../shared/utilities/editorUtilities'
1111import { getLogger } from '../../shared/logger/logger'
1212import { runtimeLanguageContext } from './runtimeLanguageContext'
1313import { fetchSupplementalContext } from './supplementalContext/supplementalContextUtil'
14- import { supplementalContextTimeoutInMs } from '../models/constants'
14+ import { editorStateMaxLength , supplementalContextTimeoutInMs } from '../models/constants'
1515import { getSelectedCustomization } from './customizationUtil'
1616import { selectFrom } from '../../shared/utilities/tsUtils'
1717import { checkLeftContextKeywordsForJson } from './commonUtil'
@@ -220,11 +220,11 @@ export function getEditorState(editor: vscode.TextEditor, fileContext: codewhisp
220220 const cursorOffset = editor . document . offsetAt ( cursorPosition )
221221 const documentText = editor . document . getText ( )
222222
223- // Check if text needs truncation (longer than 40000 characters)
223+ // Truncate if text needs truncation (longer than 40000 characters)
224224 let fileText = documentText
225- if ( documentText . length > 40000 ) {
226- const startOffset = Math . max ( 0 , cursorOffset - 20000 )
227- const endOffset = Math . min ( documentText . length , cursorOffset + 20000 )
225+ if ( documentText . length > editorStateMaxLength ) {
226+ const startOffset = Math . max ( 0 , cursorOffset - Math . floor ( editorStateMaxLength / 2 ) )
227+ const endOffset = Math . min ( documentText . length , cursorOffset + Math . floor ( editorStateMaxLength / 2 ) )
228228
229229 fileText = documentText . substring ( startOffset , endOffset )
230230 }
0 commit comments