Link and tag autocompletion activate in code blocks and inline code

Steps to reproduce

Type [[ in inline code or in code blocks

Expected result

In code blocks and inline code, typing [[ shouldn’t activate link autocompletion

Actual result

Link autocompletion appears.

Environment

  • Operating system: Windows 10 1909 64bit
  • Obsidian version: 0.9.1
1 Like

I don’t know that the right behaviour is for link autocompletion not to work in code.

Perhaps you could escape the characters to prevent autocompletion from triggering?

The code blocks and inline code don’t trigger any markdown feature (bold, italic etc.). So why should link autocompletion be different?

Well, [[links]] are not a feature of Markdown, for one. But I’m not saying you’re right or wrong, just looking to have the conversation. How might links inside code be useful? How might it be problematic? What do others think?

I’m sorry if you thought that my reply was rude. I thought it was an obvious bug.
For example, in R programming language [[ is a an operator (see here)

Besides, I have just noticed that the same happens in math expression. And it may happens to write something like this $ [[5+44]*3] $

1 Like

(No, no rudeness detected!)

Ah, interesting, didn’t know that about R.

So, in other words, the use cases for links in code/math are not outweighed by the trouble it causes when double-brackets are actually needed.

So just to add some alternative views on this.

I use snippets of Programming RFC’s for research and a lot of the older ones use tabs for formatting. So in my use case I would prefer to escape the [[ in code if I were to write R or python snippets.

So maybe (and I can’t say how feasible this is in the current architecture) a solution could be to have the Unlinked Mentions exhibit normal behaviour (linking the notes) and have a set of sensible settings that can switch off this behaviour per use case?

Steps to reproduce

In a note:

  1. type
```
#

Expected result

Due to the prevalence of # as a character of significance in programming, and the fact that the user is currently editing a multi-line code block, which are almost exclusively used for snippets of code, I would expect nothing particular to happen.

Actual result

The auto-complete fuzzy search dropdown list for existing tags was displayed.

Environment

  • Operating system: Windows 10 Pro, Version 1909, OS Build 18363.836
  • Obsidian version: 0.6.7
  • Using custom CSS: No

Additional information

Screenshot:

I can see how this is debateably a ‘bug’ and is just a design decision, and that users expect # to mean tag always. But imo the current behavior is incorrect; I was very surprised and thrown off.

1 Like

Came across this behaviour today while typing python inside a code block.

I generally agree that the suggestions are inappropriate when writing in a programming language block.

However, there may be specific types of block where the behavior is helpful, such as Obsidian’s query language, or the Data View plugin.

Perhaps a filter to allow suggestions in certain languages and not others?

Steps to reproduce

  1. Start a code block for C.
  2. Start typing a pointer declaration inside the code block fence, e.g. int *ip
  3. Observe as the editor inserts two asterisks as if you are going for emphasis: **

Expected result

Disabling of Markdown autocompletion within a code block and not having to stop and delete the additional asterisk every time.

Actual result

Trying to type int *ip I get int ** after inserting the first asterisk.

Environment

  • Operating system: Windows 10
  • Obsidian version: 0.11.5
2 Likes

I would expect both code blocks (block of text surrounded by ```) and inline code to not show the link autocompletion popup, especially since the links both don’t activate or report to the linked page as a backlink.

More importantly, I would want the code to be treated as that, code. Not markdown (or extended markdown, or Obsidian links, or anything other than code).

I am going to disagree with you and close this BR.
We now have many plugins that use codeblocks for various purposes, including special handling of text (like admonition). And you do want auto-completion in those.
Please, open a FR where you ask for selective auto-completion based on the type of codeblock. That is, if it’s text or some form of query, autocomplete, if it is code, do not autocomplete.

1 Like