mirror of
https://github.com/foambubble/foam.git
synced 2026-04-24 03:01:01 -04:00
* Addresses #1184 Currently tag completion only works in the front matter if you type a `#` character. Adding the suggested tag will then mark the tag as a comment ```markdown --- tags: #foo #bar --- ``` Update the tag completion provider to recognize if we are in the front-matter, by using adding two functions to utils.ts. Because the tag completion intellisense must be summoned with either the `#` character or the keybinding (typically `ctrl+space`), allow for 2 outcomes 1. if the tag is prefixed in the front matter with a `#`, remove it when substituting the tag. 2. If `ctrl-space` is used, recognize we are on the `tags: ` line and allow for non-`#` prefaced words. The tag provider only works on the `tags: ` within the `tags: ` key of the frontmatter. For example ```markdown --- title: A title tags: - foo - bar - | ``` (where `|` is the cursor) will provide suggestions for tags. Outside the `tags:` element, suggestions will not be provided. ```markdown --- title: A title tags: - foo - bar dates: - 2023-01-1 - | ``` * Refactor into functions for front matter & content Refactor the main provider method into two sub-functions, one for front matter, one for regular content. Add helper functions to generate the `CompletionItems` and to find the start & end indices of the last match to `#{tag}`.