Skip to content

Commit 5bc0ec9

Browse files
committed
fix: Force save file before LaTeX compilation
Auto-save has 1 second debounce delay, so clicking Compile immediately after editing compiled the old file. Now explicitly saves before compiling.
1 parent 4160004 commit 5bc0ec9

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

frontend/src/components/panels/editor/FileEditor.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,17 @@ export function FileEditor({
12411241
setLatexPdfDataUrl(null);
12421242

12431243
try {
1244+
// Force save before compiling so xelatex sees the latest content
1245+
if (fileContent !== originalContent) {
1246+
await window.electronAPI.invoke('file:write', {
1247+
sessionId,
1248+
filePath: selectedFile.path,
1249+
content: fileContent
1250+
});
1251+
setOriginalContent(fileContent);
1252+
console.log('[LaTeX] File saved before compilation');
1253+
}
1254+
12441255
const result = await window.electronAPI.invoke('file:compile-latex', {
12451256
sessionId,
12461257
filePath: selectedFile.path
@@ -1273,7 +1284,7 @@ export function FileEditor({
12731284
} finally {
12741285
setLatexCompiling(false);
12751286
}
1276-
}, [selectedFile, isLatexFile, sessionId]);
1287+
}, [selectedFile, isLatexFile, sessionId, fileContent, originalContent]);
12771288

12781289
// Keep ref in sync for Ctrl+S access
12791290
useEffect(() => {

0 commit comments

Comments
 (0)