[go: up one dir, main page]

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 a default language setting #112

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

flolbr
Copy link
Contributor
@flolbr flolbr commented Jan 2, 2024

This commit introduces the ability to set and use a default programming language for new editor blocks. Key changes include:

  • Adding a sorted list of languages and a defaultLanguage setting in the configuration.
  • Propagating the defaultLanguage setting to relevant components and functions.
  • Enabling users to select and update the default language in the settings UI.

This fixes #61

This commit introduces the ability to set and use a default programming language for new editor blocks. Key changes include:
- Adding a sorted list of languages and a `defaultLanguage` setting in the configuration.
- Propagating the `defaultLanguage` setting to relevant components and functions.
- Enabling users to select and update the default language in the settings UI.
@flolbr
Copy link
Contributor Author
flolbr commented Jan 2, 2024

I would wait to merge #85 before merging this, so it can already be up to date with the various block creation possibilities. Maybe also #102 in order to unify the settings.

Copy link
Owner
@heyman heyman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I test this, it's not woking for me. It seems like the the block immediately changes back to Plain Text (auto). IIRC there might be some code that automatically resets an auto-block to text-a if the content is empty.

Maybe it would make sense to also include a setting for if new blocks should have auto detection turned on?

Maybe also #102 in order to unify the settings.

I've merged #102 where I also added an Editing tab in the settings, as well as some tests. This PR should get some tests as well.

@@ -1,5 +1,36 @@
import Store from "electron-store"

let sortedLanguages = [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we build this list from src/editor/languages.js?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to, but ended up having issues because the editor subdirectory belongs to the view, whereas the config is the electron side. Ideally, the way I would want it to work is to do a static generation at build time, like I did for the README/initial-content.

As for the text reverting back to plain text, I guess we could only append -a at the end of a new block if the default language is set to Plain Text.

@heyman
Copy link
Owner
heyman commented Jan 4, 2024

As for the text reverting back to plain text, I guess we could only append -a at the end of a new block if the default language is set to Plain Text.

I think it makes sense to be able to change the default mode for newly created blocks but still have auto-detection turned on for them (but we should have a setting for this).

I also think it makes sense for an auto block that is emptied (e.g. uses presses Ctrl-A Backspace) to change its language back to the default. Therefore, I think we should make sure that we revert back to the default - instead of always text - to resolve the issue of blocks getting reverted back to Plain Text (if that is the issue, I haven't confirmed it).

@flolbr
Copy link
Contributor Author
flolbr commented Jan 10, 2024

Isn't the issue that it reverts to Plain Text too early, while there aren't enough characters for the "syntax matcher" to work properly ?

@heyman
Copy link
Owner
heyman commented Jan 11, 2024

Isn't the issue that it reverts to Plain Text too early, while there aren't enough characters for the "syntax matcher" to work properly ?

When a block is "cleared" (e.g. the user press Ctrl-A Backspace) I think it makes sense that the block reverts back to the default mode immediately (for auto blocks that is).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default language setting
2 participants