diff --git a/content.js b/content.js index 017551a..6fe2303 100644 --- a/content.js +++ b/content.js @@ -252,20 +252,24 @@ function getCellContentTextRequiredForBigCode(activeCell) { // in active cell, LeftContext refers to the left side of the pointer, and vice versa, If both are null, it is determined that the pointer is not at the far right const [leftContext, rightContext] = getActiveCellPointerCode(activeCell) - if(!leftContext && !rightContext){ + if(!leftContext){ return null } - TODO: "The following code needs to add 'leftContext' and 'rightContext'" + TODO: "The following code needs to add 'rightContext'" // Iterate through the last 3 cells before the active cell const startIndex = activeCellIndex - 3 < 0 ? 0 : activeCellIndex - 3; for (let i = startIndex; i <= activeCellIndex; i++) { + if(i == activeCellIndex){ + combinedContent += `${leftContext}`; + continue + } + const cellElement = cellElements[i]; if (cellElement.classList.contains('code_cell')) { const code = extractTextFromCell(cellElement); - combinedContent += `${code}`; const outputElement = cellElement.querySelector('.output_subarea'); if (outputElement) { @@ -303,13 +307,11 @@ function extractTextFromCell(cell) { codeMirrorLines.forEach((line) => { content.push(line.textContent); }); - const content_str = content.join('\n'); - return content_str; + return content.join('\n'); } - // 开始等待动画,有30s等待时间,如果等待时间过了,出现“error”字体,返回两个值如下,接收:"const [animationInterval, animationElement] = startWaitingAnimation(activeCall)" // 1. animationInterval(interval, 动画计时器),可使用clearInterval(animationInterval)消除动画, 每次请求完毕必须要关掉 // 2. animationElement (dom, 动画字体节点), animationElement.innerHTML = xxx 来赋值