Commit ·
aa88455
1
Parent(s): b829513
revert: remove auto re-analyze after apply - causes grammar/punctuation cycle
Browse filesGrammar removes period, punctuation re-adds it. Auto re-analyze after apply
creates an infinite cycle. Analysis already auto-triggers when user types
(input event handler), which is the correct behavior.
- src/js/editor.js +1 -20
src/js/editor.js
CHANGED
|
@@ -10,9 +10,6 @@ const MAX_ANALYZE_LENGTH = 5000;
|
|
| 10 |
// Pipeline Hardening v3.3: Guard to prevent input events during suggestion apply
|
| 11 |
let _isApplyingSuggestion = false;
|
| 12 |
|
| 13 |
-
// Track last analyzed text to prevent redundant API calls
|
| 14 |
-
let _lastAnalyzedText = '';
|
| 15 |
-
|
| 16 |
// ── Custom Undo/Redo Stack ──
|
| 17 |
const _undoStack = [];
|
| 18 |
const _redoStack = [];
|
|
@@ -246,7 +243,7 @@ function findSuggestionElement(id) {
|
|
| 246 |
return document.querySelector(`[data-suggestion-id="${id}"]`);
|
| 247 |
}
|
| 248 |
|
| 249 |
-
async function analyzeText(
|
| 250 |
const text = getEditorText();
|
| 251 |
updateEditorStats();
|
| 252 |
updatePlaceholder();
|
|
@@ -258,14 +255,9 @@ async function analyzeText(forceReanalyze = false) {
|
|
| 258 |
updateSuggestionsList([]);
|
| 259 |
window.currentSuggestions = [];
|
| 260 |
updateAnalysisLimitBanner(false);
|
| 261 |
-
_lastAnalyzedText = '';
|
| 262 |
return;
|
| 263 |
}
|
| 264 |
|
| 265 |
-
// Skip redundant analysis if text hasn't changed (prevents overlay→input→analyze loop)
|
| 266 |
-
if (!forceReanalyze && text === _lastAnalyzedText) return;
|
| 267 |
-
_lastAnalyzedText = text;
|
| 268 |
-
|
| 269 |
const isTruncated = text.length > MAX_ANALYZE_LENGTH;
|
| 270 |
const textForApi = isTruncated ? text.substring(0, MAX_ANALYZE_LENGTH) : text;
|
| 271 |
updateAnalysisLimitBanner(isTruncated);
|
|
@@ -528,11 +520,6 @@ function applySuggestionAtOffsets(suggestion) {
|
|
| 528 |
} finally {
|
| 529 |
_isApplyingSuggestion = false;
|
| 530 |
}
|
| 531 |
-
// P2/User Request: Auto re-analyze after applying suggestion
|
| 532 |
-
// Calls analyzeText() DIRECTLY (not delayed) for instant re-analysis.
|
| 533 |
-
// forceReanalyze=true because the text changed (suggestion was applied)
|
| 534 |
-
_lastAnalyzedText = ''; // Reset so analysis isn't skipped
|
| 535 |
-
setTimeout(() => { analyzeText(); }, 300);
|
| 536 |
}
|
| 537 |
|
| 538 |
function applyCorrection() {
|
|
@@ -616,9 +603,6 @@ function applyAlternativeCorrection(suggestion, correctionText) {
|
|
| 616 |
} finally {
|
| 617 |
_isApplyingSuggestion = false;
|
| 618 |
}
|
| 619 |
-
// P2/User Request: Auto re-analyze after applying alternative correction
|
| 620 |
-
_lastAnalyzedText = ''; // Reset so analysis isn't skipped
|
| 621 |
-
setTimeout(() => { analyzeText(); }, 300);
|
| 622 |
}
|
| 623 |
|
| 624 |
function dismissSuggestion(suggestion) {
|
|
@@ -698,9 +682,6 @@ function applyAllSuggestions() {
|
|
| 698 |
} finally {
|
| 699 |
_isApplyingSuggestion = false;
|
| 700 |
}
|
| 701 |
-
// P2/User Request: Auto re-analyze after applying all suggestions
|
| 702 |
-
_lastAnalyzedText = ''; // Reset so analysis isn't skipped
|
| 703 |
-
setTimeout(() => { analyzeText(); }, 300);
|
| 704 |
}
|
| 705 |
|
| 706 |
function clearEditor() {
|
|
|
|
| 10 |
// Pipeline Hardening v3.3: Guard to prevent input events during suggestion apply
|
| 11 |
let _isApplyingSuggestion = false;
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
// ── Custom Undo/Redo Stack ──
|
| 14 |
const _undoStack = [];
|
| 15 |
const _redoStack = [];
|
|
|
|
| 243 |
return document.querySelector(`[data-suggestion-id="${id}"]`);
|
| 244 |
}
|
| 245 |
|
| 246 |
+
async function analyzeText() {
|
| 247 |
const text = getEditorText();
|
| 248 |
updateEditorStats();
|
| 249 |
updatePlaceholder();
|
|
|
|
| 255 |
updateSuggestionsList([]);
|
| 256 |
window.currentSuggestions = [];
|
| 257 |
updateAnalysisLimitBanner(false);
|
|
|
|
| 258 |
return;
|
| 259 |
}
|
| 260 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 261 |
const isTruncated = text.length > MAX_ANALYZE_LENGTH;
|
| 262 |
const textForApi = isTruncated ? text.substring(0, MAX_ANALYZE_LENGTH) : text;
|
| 263 |
updateAnalysisLimitBanner(isTruncated);
|
|
|
|
| 520 |
} finally {
|
| 521 |
_isApplyingSuggestion = false;
|
| 522 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 523 |
}
|
| 524 |
|
| 525 |
function applyCorrection() {
|
|
|
|
| 603 |
} finally {
|
| 604 |
_isApplyingSuggestion = false;
|
| 605 |
}
|
|
|
|
|
|
|
|
|
|
| 606 |
}
|
| 607 |
|
| 608 |
function dismissSuggestion(suggestion) {
|
|
|
|
| 682 |
} finally {
|
| 683 |
_isApplyingSuggestion = false;
|
| 684 |
}
|
|
|
|
|
|
|
|
|
|
| 685 |
}
|
| 686 |
|
| 687 |
function clearEditor() {
|