Skip to content

Commit 72d4f4e

Browse files
authored
Update main.js
1 parent 6c67077 commit 72d4f4e

1 file changed

Lines changed: 49 additions & 98 deletions

File tree

src/main.js

Lines changed: 49 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -5045,7 +5045,7 @@ Make cleaner, more efficient. Same functionality.`;
50455045
if (this.realTimeEnabled) {
50465046
window.toast("Real-time Renz Ai enabled ✨", 3000);
50475047
this.showRealTimeStatus(true);
5048-
this.analyzeCurrentFile();
5048+
this.analyzeCurrentCode();
50495049
} else {
50505050
window.toast("Real-time Renz Ai disabled", 2000);
50515051
this.showRealTimeStatus(false);
@@ -5208,37 +5208,6 @@ Focus cursor area only.`;
52085208
}
52095209
}
52105210

5211-
applySuggestions(analysis) {
5212-
// Clear previous suggestions
5213-
this.clearSuggestions();
5214-
this.clearErrorMarkers();
5215-
5216-
// Apply syntax error markers
5217-
if (analysis.syntax_errors && analysis.syntax_errors.length > 0) {
5218-
this.showSyntaxErrors(analysis.syntax_errors);
5219-
}
5220-
5221-
// Show missing imports
5222-
if (analysis.missing_imports && analysis.missing_imports.length > 0) {
5223-
this.showMissingImports(analysis.missing_imports);
5224-
}
5225-
5226-
// Show code suggestions
5227-
if (analysis.code_suggestions && analysis.code_suggestions.length > 0) {
5228-
this.showCodeSuggestions(analysis.code_suggestions);
5229-
}
5230-
5231-
// Show auto-complete
5232-
if (analysis.auto_complete && analysis.auto_complete.length > 0) {
5233-
this.showAutoComplete(analysis.auto_complete);
5234-
}
5235-
5236-
// Show quick fixes
5237-
if (analysis.quick_fixes && analysis.quick_fixes.length > 0) {
5238-
this.showQuickFixes(analysis.quick_fixes);
5239-
}
5240-
}
5241-
52425211
showSyntaxErrors(errors) {
52435212
errors.forEach(error => {
52445213
const marker = editor.session.addMarker(
@@ -5392,46 +5361,49 @@ Focus cursor area only.`;
53925361
const cursorPos = editor.getCursorPosition();
53935362
const screenPos = editor.renderer.textToScreenCoordinates(cursorPos.row, cursorPos.column);
53945363

5395-
if (this.currentSuggestions.length > 0) {
5396-
this.suggestionWidget.innerHTML = '';
5364+
if (this.currentSuggestions.length > 0) {
5365+
this.suggestionWidget.innerHTML = '';
53975366

5398-
this.currentSuggestions.forEach(suggestion => {
5399-
const suggestionItem = tag("div", {
5400-
textContent: suggestion.text || suggestion,
5401-
style: `
5402-
padding: 4px 8px;
5403-
cursor: pointer;
5404-
border-radius: 2px;
5405-
margin: 2px 0;
5406-
`,
5407-
className: "suggestion-item"
5408-
});
5367+
this.currentSuggestions.forEach(suggestion => {
5368+
const suggestionItem = tag("div", {
5369+
textContent: suggestion.text || suggestion,
5370+
style: `
5371+
padding: 4px 8px;
5372+
cursor: pointer;
5373+
border-radius: 2px;
5374+
margin: 2px 0;
5375+
`,
5376+
className: "suggestion-item"
5377+
});
54095378

5410-
suggestionItem.onmouseenter = () => {
5411-
suggestionItem.style.background = '#333';
5412-
};
5379+
suggestionItem.onmouseenter = () => {
5380+
suggestionItem.style.background = '#333';
5381+
};
54135382

5414-
suggestionItem.onmouseleave = () => {
5415-
suggestionItem.style.background = 'transparent';
5416-
};
5383+
suggestionItem.onmouseleave = () => {
5384+
suggestionItem.style.background = 'transparent';
5385+
};
54175386

5418-
suggestionItem.onclick = () => {
5419-
this.applySuggestion(suggestion);
5420-
this.hideSuggestionWidget();
5421-
};
5387+
suggestionItem.onclick = () => {
5388+
this.applySuggestions(suggestion);
5389+
this.hideSuggestionWidget();
5390+
};
54225391

5423-
this.suggestionWidget.appendChild(suggestionItem);
5424-
});
5392+
this.suggestionWidget.appendChild(suggestionItem);
5393+
});
54255394

5426-
// Position widget
5427-
this.suggestionWidget.style.left = screenPos.pageX + 'px';
5428-
this.suggestionWidget.style.top = (screenPos.pageY + 20) + 'px';
5429-
this.suggestionWidget.style.display = 'block';
5395+
// Position widget
5396+
this.suggestionWidget.style.left = screenPos.pageX + 'px';
5397+
this.suggestionWidget.style.top = (screenPos.pageY + 20) + 'px';
5398+
this.suggestionWidget.style.display = 'block';
54305399

5431-
// Auto hide after 5 seconds
5432-
setTimeout(() => {
5433-
this.hideSuggestionWidget();
5434-
}, 5000);
5400+
// Auto hide after 5 seconds
5401+
setTimeout(() => {
5402+
this.hideSuggestionWidget();
5403+
}, 5000);
5404+
}
5405+
} catch (error) {
5406+
window.toast('Error showing contextual suggestions', 3000);
54355407
}
54365408
}
54375409

@@ -5447,11 +5419,15 @@ Focus cursor area only.`;
54475419
}
54485420

54495421
clearErrorMarkers() {
5450-
this.errorMarkers.forEach(marker => {
5451-
editor.session.removeMarker(marker);
5452-
});
5453-
this.errorMarkers = [];
5454-
editor.session.clearAnnotations();
5422+
if (this.errorMarkers) {
5423+
this.errorMarkers.forEach(marker => {
5424+
editor.session.removeMarker(marker);
5425+
});
5426+
this.errorMarkers = [];
5427+
}
5428+
if (editor && editor.session) {
5429+
editor.session.clearAnnotations();
5430+
}
54555431
}
54565432

54575433
createSuggestionWidget() {
@@ -5517,7 +5493,7 @@ Focus cursor area only.`;
55175493

55185494
// Add click handler
55195495
item.addEventListener('click', () => {
5520-
this.applySuggestion(suggestion);
5496+
this.applySuggestions(suggestion);
55215497
this.suggestionWidget.style.display = 'none';
55225498
});
55235499

@@ -5752,7 +5728,7 @@ Focus cursor area only.`;
57525728
return icons[severity] || '❌';
57535729
}
57545730

5755-
applySuggestion(suggestion) {
5731+
applySuggestions(suggestion) {
57565732
try {
57575733
if (!editor || !suggestion) return;
57585734

@@ -5779,7 +5755,6 @@ Focus cursor area only.`;
57795755

57805756
} catch (error) {
57815757
window.toast('Error applying suggestion', 3000);
5782-
window.toast('Error applying suggestion', 3000);
57835758
}
57845759
}
57855760

@@ -5878,29 +5853,6 @@ Focus cursor area only.`;
58785853
}
58795854
}
58805855

5881-
async analyzeCurrentFile() {
5882-
if (!this.realTimeEnabled) return;
5883-
5884-
const activeFile = editorManager.activeFile;
5885-
if (!activeFile) return;
5886-
5887-
const content = editor.getValue();
5888-
if (content.trim().length === 0) return;
5889-
5890-
try {
5891-
const analysis = await this.performRealTimeAnalysis(
5892-
content,
5893-
editor.session.getLine(editor.getCursorPosition().row),
5894-
editor.getCursorPosition(),
5895-
activeFile
5896-
);
5897-
5898-
this.applySuggestions(analysis);
5899-
} catch (error) {
5900-
window.toast('File analysis error', 3000);
5901-
}
5902-
}
5903-
59045856
async destroy() {
59055857
try {
59065858
// Clear all intervals
@@ -6105,7 +6057,6 @@ Focus cursor area only.`;
61056057
window.toast("Error during plugin destruction", 3000);
61066058
}
61076059
}
6108-
61096060
}
61106061

61116062
if (window.acode) {
@@ -6118,7 +6069,7 @@ if (window.acode) {
61186069
}
61196070
acodePlugin.baseUrl = baseUrl;
61206071
acodePlugin.init($page, cacheFile, cacheFileUrl);
6121-
},
6072+
}
61226073
);
61236074
acode.setPluginUnmount(plugin.id, () => {
61246075
acodePlugin.destroy();

0 commit comments

Comments
 (0)