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

With VS Code extension, "Quarto: Insert Code Cell" requires user to choose language for each new chunk #425

Closed
juliasilge opened this issue Apr 26, 2024 · 5 comments · Fixed by #540

Comments

@juliasilge
Copy link
Collaborator

When using the VS Code extension, you can use "Quarto: Insert Code Cell" (such as via its keyboard shortcut) to make a new code cell/chunk. However, it requires the user to choose the language every time:

new-chunk.mov

We are hearing from users that they would prefer the RStudio behavior where making a new code chunk uses the language from the previous code chunk. It is fine to have users choose for the first chunk, but it doesn't feel great to have to keep choosing the language over and over.

@mcanouil
Copy link
Contributor

FYI:

@mikemahoney218
Copy link

A bit of a delayed response but FWIW, I think this is meaningfully distinct from #405. Ideally this would mean the language of each file is detected, irrespective of user profile settings, and automatically populated for all but the first cell.

@jennybc
Copy link
Collaborator

jennybc commented Aug 26, 2024

I'm bumping into this very hard right now, working on many existing .Rmd vignettes in a package. I did upvote above, but that didn't seem like a strong enough endorsement for this issue 😅 It would be really awesome to not have to replace python with r repeatedly. The current situation feels pretty hostile to an R user. (I'm experiencing this with an .Rmd not a .qmd but I assume it's for the same reasons / would have the same fix? Although you could argue for a default of r in .Rmd)

@DavisVaughan
Copy link
Collaborator

See #539 for the direct comparison with RStudio, strongly agree we should tweak this

@DavisVaughan
Copy link
Collaborator

Looks super easy, let me give it a shot

// order by language
const allLangs = ['python', 'r', 'julia', 'ojs', 'sql', 'bash', 'mermaid', 'dot'];
const languages = language
? [language, allLangs.filter(lang => lang !== language)]
: allLangs;
// insert snippet
await commands.executeCommand("editor.action.insertSnippet", {
snippet: [
...(insertTopPaddingLine ? [""] : []),
"```{${1|" + languages.join(",") + "|}}",
"${TM_SELECTED_TEXT}$0",
"```"
].join("\n"),
});
}
}

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 a pull request may close this issue.

5 participants