posit-dev / positron

Positron, a next-generation data science IDE
https://positron.posit.co
Other
2.79k stars 85 forks source link

Markdown R code chunk inserts <> upon < #4643

Open aronatkins opened 2 months ago

aronatkins commented 2 months ago

System details:

Positron and OS details:

Positron Version: 2024.09.0 (Universal) build 27 Code - OSS Version: 1.92.0 Commit: d996153f3be6bcc9af460300e61103425323b973 Date: 2024-09-11T02:38:46.408Z Electron: 30.1.2 Chromium: 124.0.6367.243 Node.js: 20.14.0 V8: 12.4.254.20-electron.0 OS: Darwin arm64 23.6.0

Interpreter details:

NA.

Describe the issue:

While editing an R code block in a simple Markdown document, the <> character sequence is inserted when < is input. This means that an additional character is injected into the document any time an R variable assignment is typed.

Steps to reproduce the issue:

Starting with the simple document:

```r


Within the code block, attempt to type `v <- 42`. The document will contain `v <- 42>` (assuming you do not intentionally delete the trailing `>` that was added).

## Expected or desired behavior:

What I type is what I get and there is no automatic addition of `<` when in an R code block.

This is not exclusive to R. The same insertion happens in Python code blocks, too. Try to use the less-than symbol in a Python expression, for example. You'll have an additional `>` character.

Here is an R and Python example before cleaning up the extraneous characters.

<img width="205" alt="image" src="https://github.com/user-attachments/assets/1994cbaf-ed2d-4275-ae4c-fdb7f757b05b">

## Were there any error messages in the UI, Output panel, or Developer Tools console?

<!--

- Open the Developer Tools console by running the `Developer: Toggle Developer Tools` command from the Command Palette
- Open the relevant Output Channel logs by utilizing this guide https://github.com/posit-dev/positron/wiki/Troubleshooting

-->
juliasilge commented 2 months ago

This happens because angle brackets are one of the autoclosing pairs for markdown:

https://github.com/posit-dev/positron/blob/f5cd27fdf143d8dde3edcc19dc9ad3b71ad1440c/extensions/markdown-basics/language-configuration.json#L39-L40

aronatkins commented 2 months ago

I originally encountered this problem while editing an R code block in a README.md file, but have seen it in other simple Markdown files (usually a *.md for notes alongside some other code). I've shifted to *.qmd in non-README contexts.