Remove reliance on document.lineAt (#154191)

* Remove reliance on document.lineAt

This helps aligning more with the LSP types: https://github.com/microsoft/vscode-languageserver-node/issues/146

* Strip newline
This commit is contained in:
Matt Bierner
2022-07-05 11:52:47 -07:00
committed by GitHub
parent 510a74fc2c
commit fc0bd9d377
9 changed files with 40 additions and 47 deletions

View File

@@ -9,7 +9,7 @@ import * as uri from 'vscode-uri';
import { OpenDocumentLinkCommand } from '../commands/openDocumentLink';
import { ILogger } from '../logging';
import { IMdParser } from '../markdownEngine';
import { ITextDocument } from '../types/textDocument';
import { getLine, ITextDocument } from '../types/textDocument';
import { coalesce } from '../util/arrays';
import { noopToken } from '../util/cancellation';
import { Disposable } from '../util/dispose';
@@ -422,9 +422,9 @@ export class MdLinkComputer {
reference = match[5];
const offset = ((match.index ?? 0) + match[1].length) + 1;
hrefStart = document.positionAt(offset);
const line = document.lineAt(hrefStart.line);
const line = getLine(document, hrefStart.line);
// See if link looks like a checkbox
const checkboxMatch = line.text.match(/^\s*[\-\*]\s*\[x\]/i);
const checkboxMatch = line.match(/^\s*[\-\*]\s*\[x\]/i);
if (checkboxMatch && hrefStart.character <= checkboxMatch[0].length) {
continue;
}