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

Don't fallback to the empty string for language in the DiffEditor to give Monaco a chance to deduce the langauge from paths #582

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SethBacaner
Copy link

@SethBacaner SethBacaner commented Jan 30, 2024

Because originalLanguage and modifiedLanguage fallback to text in DiffEditor, Monaco will treat the contents as text and never try to infer the language from originalModelPath and modifiedModelPath. In Editor, language falls back to the empty string.

// Does not detect TypeScript.
<DiffEditor
    original="const a = 1;"
    modified="const a = 2;"
    originalModelPath="file.ts"
    modifiedModelPath="file.ts"
/>

// Has no problem detecting TypeScript.
<Editor
    value="const a = 1;"
    path="file.ts"
/>

This change updates DiffEditor to match the behavior of Editor.

@suren-atoyan
Copy link
Owner

Thank for your support @SethBacaner 🙌

Looks good, I'll test it and release a new version at the end of the week.

@SethBacaner
Copy link
Author

@suren-atoyan 👋 did you ever get a chance to look at this further?

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.

2 participants