fix(editor): fix positions of tag migration lint

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2023-10-08 14:53:56 +02:00
parent 18e1ab340c
commit 386cf469fd
2 changed files with 7 additions and 7 deletions

View file

@ -45,8 +45,8 @@ describe('FrontmatterLinter', () => {
testFrontmatterLinter(
'---\ntags: a\n---',
{
from: 5,
to: 12,
from: 4,
to: 11,
severity: 'warning'
},
'tags:\n- a'
@ -56,8 +56,8 @@ describe('FrontmatterLinter', () => {
testFrontmatterLinter(
'---\ntags: 1\n---',
{
from: 5,
to: 12,
from: 4,
to: 11,
severity: 'warning'
},
'tags:\n- 1'
@ -67,8 +67,8 @@ describe('FrontmatterLinter', () => {
testFrontmatterLinter(
'---\ntags: 123, a\n---',
{
from: 5,
to: 17,
from: 4,
to: 16,
severity: 'warning'
},
'tags:\n- 123\n- a'

View file

@ -60,7 +60,7 @@ export class FrontmatterLinter implements Linter {
const replacedText = 'tags:\n- ' + tags.join('\n- ')
const tagsLineIndex = frontmatterLines.findIndex((value) => value.startsWith('tags: '))
const linesBeforeTagsLine = frontmatterLines.slice(0, tagsLineIndex)
const from = startOfYaml + linesBeforeTagsLine.join('\n').length + 1
const from = startOfYaml + linesBeforeTagsLine.join('\n').length + linesBeforeTagsLine.length
const to = from + frontmatterLines[tagsLineIndex].length
return [
{