* Toggles the visibility of the problem button based on the presence of annotations in the files.
(file)
| 2758 | * Toggles the visibility of the problem button based on the presence of annotations in the files. |
| 2759 | */ |
| 2760 | function fileHasProblems(file) { |
| 2761 | const state = getDiagnosticStateForFile(file); |
| 2762 | if (!state) return false; |
| 2763 | |
| 2764 | const session = file.session; |
| 2765 | if (session && typeof session.getAnnotations === "function") { |
| 2766 | try { |
| 2767 | const annotations = session.getAnnotations() || []; |
| 2768 | if (annotations.length) return true; |
| 2769 | } catch (error) { |
| 2770 | warnRecoverable( |
| 2771 | "Failed to read editor annotations while checking problems.", |
| 2772 | error, |
| 2773 | "read-annotations", |
| 2774 | ); |
| 2775 | } |
| 2776 | } |
| 2777 | |
| 2778 | if (typeof state.field !== "function") return false; |
| 2779 | try { |
| 2780 | const diagnostics = getLspDiagnostics(state); |
| 2781 | return diagnostics.length > 0; |
| 2782 | } catch (error) { |
| 2783 | warnRecoverable( |
| 2784 | "Failed to read LSP diagnostics while checking problems.", |
| 2785 | error, |
| 2786 | "read-lsp-diagnostics", |
| 2787 | ); |
| 2788 | } |
| 2789 | |
| 2790 | return false; |
| 2791 | } |
| 2792 | |
| 2793 | function toggleProblemButton() { |
| 2794 | const { showSideButtons } = appSettings.value; |
no test coverage detected