Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to disable autoclosing brackets in the editor #2805

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion assets/js/hooks/cell_editor/live_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ export default class LiveEditor {
"&": { fontSize: `${settings.editor_font_size}px` },
});

const autoCloseBracketsEnabled = settings.editor_auto_close_brackets;

const ligaturesTheme = EditorView.theme({
"&": {
fontVariantLigatures: `${settings.editor_ligatures ? "normal" : "none"}`,
Expand Down Expand Up @@ -354,7 +356,7 @@ export default class LiveEditor {
crosshairCursor(),
EditorState.allowMultipleSelections.of(true),
bracketMatching(),
closeBrackets(),
autoCloseBracketsEnabled ? closeBrackets() : [],
indentOnInput(),
history(),
EditorState.readOnly.of(this.readOnly),
Expand Down
11 changes: 11 additions & 0 deletions assets/js/hooks/editor_settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const EditorSettings = {
const editorAutoSignatureCheckbox = this.el.querySelector(
`[name="editor_auto_signature"][value="true"]`,
);
const editorAutoCloseBracketsCheckbox = this.el.querySelector(
`[name="editor_auto_close_brackets"][value="true"]`,
);
const editorFontSizeCheckbox = this.el.querySelector(
`[name="editor_font_size"][value="true"]`,
);
Expand All @@ -33,6 +36,8 @@ const EditorSettings = {

editorAutoCompletionCheckbox.checked = settings.editor_auto_completion;
editorAutoSignatureCheckbox.checked = settings.editor_auto_signature;
editorAutoCloseBracketsCheckbox.checked =
settings.editor_auto_close_brackets;
editorFontSizeCheckbox.checked =
settings.editor_font_size === EDITOR_FONT_SIZE.large ? true : false;
editorLigaturesCheckbox.checked = settings.editor_ligatures;
Expand All @@ -49,6 +54,12 @@ const EditorSettings = {
settingsStore.update({ editor_auto_signature: event.target.checked });
});

editorAutoCloseBracketsCheckbox.addEventListener("change", (event) => {
settingsStore.update({
editor_auto_close_brackets: event.target.checked,
});
});

editorFontSizeCheckbox.addEventListener("change", (event) => {
settingsStore.update({
editor_font_size: event.target.checked
Expand Down
1 change: 1 addition & 0 deletions assets/js/lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const EDITOR_THEME = {
const DEFAULTSETTINGS = {
editor_auto_completion: true,
editor_auto_signature: true,
editor_auto_close_brackets: true,
editor_font_size: EDITOR_FONT_SIZE.normal,
editor_theme: EDITOR_THEME.default,
editor_ligatures: false,
Expand Down
5 changes: 5 additions & 0 deletions lib/livebook_web/live/settings_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ defmodule LivebookWeb.SettingsLive do
label="Show function signature while typing"
value={false}
/>
<.switch_field
name="editor_auto_close_brackets"
label="Automatically close brackets"
value={false}
/>
<.switch_field name="editor_font_size" label="Increase font size" value={false} />
<.switch_field name="editor_ligatures" label="Render ligatures" value={false} />
<.switch_field name="editor_light_theme" label="Use light theme" value={false} />
Expand Down
Loading