Skip to content

Commit

Permalink
Fix crash if using groovy and editing ruff settings
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrunyon committed Sep 20, 2024
1 parent f606c0a commit 0b89ed9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/console/src/monaco/RuffSettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ export default function RuffSettingsModal({
const [isValid, setIsValid] = useState(false);
const [isDefault, setIsDefault] = useState(false);
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor>();
const [ruffVersion] = useState(() => Workspace.version() ?? '');
const [ruffVersion] = useState(() => {
// This throws if using Groovy or Ruff is not loaded
try {
return `v${Workspace.version()}` ?? '';
} catch {
return '';
}
});
const [model] = useState(() =>
monaco.editor.createModel(text, 'json', RUFF_SETTINGS_URI)
);
Expand Down Expand Up @@ -141,7 +148,7 @@ export default function RuffSettingsModal({
>
<ModalHeader closeButton={false}>
<span className="settings-modal-title mr-auto">
Ruff v{ruffVersion} Settings
Ruff {ruffVersion} Settings
</span>

<Link href="https://docs.astral.sh/ruff/settings/" target="_blank">
Expand Down

0 comments on commit 0b89ed9

Please sign in to comment.