diff --git a/server/src/embeddedSupport/vueDocumentRegionParser.ts b/server/src/embeddedSupport/vueDocumentRegionParser.ts
index 2b0e98a6d4..bf7b5a28df 100644
--- a/server/src/embeddedSupport/vueDocumentRegionParser.ts
+++ b/server/src/embeddedSupport/vueDocumentRegionParser.ts
@@ -159,7 +159,7 @@ function scanTemplateRegion(scanner: Scanner, text: string): EmbeddedRegion | nu
} else if (token === HtmlTokenType.Unknown) {
if (scanner.getTokenText().charAt(0) === '<') {
const offset = scanner.getTokenOffset();
- const unknownText = text.substr(offset, 11);
+ const unknownText = text.slice(offset, offset + 11);
if (unknownText === '') {
unClosedTemplate--;
// test leading
@@ -231,7 +231,7 @@ function scanCustomRegion(tagName: string, scanner: Scanner, text: string): Embe
} else if (token === HtmlTokenType.Unknown) {
if (scanner.getTokenText().charAt(0) === '<') {
const offset = scanner.getTokenOffset();
- const unknownText = text.substr(offset, `${tagName}>`.length);
+ const unknownText = text.slice(offset, offset + `${tagName}>`.length);
if (unknownText === `${tagName}>`) {
unClosedTag--;
// test leading ${tagName}>
diff --git a/server/src/modes/script/previewer.ts b/server/src/modes/script/previewer.ts
index 6663004508..3ecb1f232a 100644
--- a/server/src/modes/script/previewer.ts
+++ b/server/src/modes/script/previewer.ts
@@ -51,7 +51,7 @@ function getTagBodyText(tag: ts.JSDocTagInfo): string | undefined {
// check for caption tags, fix for #79704
const captionTagMatches = plain(tag.text).match(/
(.*?)<\/caption>\s*(\r\n|\n)/);
if (captionTagMatches && captionTagMatches.index === 0) {
- return captionTagMatches[1] + '\n\n' + makeCodeblock(plain(tag.text).substr(captionTagMatches[0].length));
+ return captionTagMatches[1] + '\n\n' + makeCodeblock(plain(tag.text).slice(captionTagMatches[0].length));
} else {
return makeCodeblock(plain(tag.text));
}
diff --git a/server/src/modes/template/parser/htmlScanner.ts b/server/src/modes/template/parser/htmlScanner.ts
index d8571ee57a..2e66849fa3 100644
--- a/server/src/modes/template/parser/htmlScanner.ts
+++ b/server/src/modes/template/parser/htmlScanner.ts
@@ -102,7 +102,7 @@ class MultiLineStream {
}
public advanceIfRegExp(regex: RegExp): string {
- const str = this.source.substr(this.position);
+ const str = this.source.slice(this.position);
const match = str.match(regex);
if (match) {
this.position = this.position + match.index! + match[0].length;
@@ -112,7 +112,7 @@ class MultiLineStream {
}
public advanceUntilRegExp(regex: RegExp): string {
- const str = this.source.substr(this.position);
+ const str = this.source.slice(this.position);
const match = str.match(regex);
if (match) {
this.position = this.position + match.index!;
diff --git a/server/src/modes/template/test/highlighting.test.ts b/server/src/modes/template/test/highlighting.test.ts
index 37254b1641..906730ae1f 100644
--- a/server/src/modes/template/test/highlighting.test.ts
+++ b/server/src/modes/template/test/highlighting.test.ts
@@ -12,7 +12,7 @@ import { findDocumentHighlights } from '../services/htmlHighlighting';
suite('HTML Highlighting', () => {
function assertHighlights(value: string, expectedMatches: number[], elementName: string | null): void {
const offset = value.indexOf('|');
- value = value.substr(0, offset) + value.substr(offset + 1);
+ value = value.slice(0, offset) + value.slice(offset + 1);
const document = TextDocument.create('test://test/test.html', 'html', 0, value);
diff --git a/server/src/modes/template/test/scanner.test.ts b/server/src/modes/template/test/scanner.test.ts
index 63436a1271..f0d18c1a1f 100644
--- a/server/src/modes/template/test/scanner.test.ts
+++ b/server/src/modes/template/test/scanner.test.ts
@@ -23,7 +23,10 @@ suite('HTML Scanner', () => {
while (tokenType !== HtmlTokenType.EOS) {
const actualToken: Token = { offset: scanner.getTokenOffset(), type: tokenType };
if (tokenType === HtmlTokenType.StartTag || tokenType === HtmlTokenType.EndTag) {
- actualToken.content = t.input.substr(scanner.getTokenOffset(), scanner.getTokenLength());
+ actualToken.content = t.input.slice(
+ scanner.getTokenOffset(),
+ scanner.getTokenOffset() + scanner.getTokenLength()
+ );
}
actual.push(actualToken);
tokenType = scanner.scan();
diff --git a/server/src/modes/test-util/completion-test-util.ts b/server/src/modes/test-util/completion-test-util.ts
index 2734df690d..3a1f40b3ee 100644
--- a/server/src/modes/test-util/completion-test-util.ts
+++ b/server/src/modes/test-util/completion-test-util.ts
@@ -18,7 +18,7 @@ export interface CompletionTestSetup {
export function testDSL(setup: CompletionTestSetup): (text: TemplateStringsArray) => CompletionAsserter {
return function test([value]: TemplateStringsArray) {
const offset = value.indexOf('|');
- value = value.substr(0, offset) + value.substr(offset + 1);
+ value = value.substring(0, offset) + value.slice(offset + 1);
const document = TextDocument.create(setup.docUri, setup.langId, 0, value);
const position = document.positionAt(offset);
diff --git a/server/src/modes/test-util/hover-test-util.ts b/server/src/modes/test-util/hover-test-util.ts
index 358eb41f8f..9944fd7e52 100644
--- a/server/src/modes/test-util/hover-test-util.ts
+++ b/server/src/modes/test-util/hover-test-util.ts
@@ -34,7 +34,7 @@ export class HoverAsserter {
export function hoverDSL(setup: HoverTestSetup) {
return function test([value]: TemplateStringsArray) {
const offset = value.indexOf('|');
- value = value.substr(0, offset) + value.substr(offset + 1);
+ value = value.slice(0, offset) + value.slice(offset + 1);
const document = TextDocument.create(setup.docUri, setup.langId, 0, value);
const position = document.positionAt(offset);
diff --git a/server/src/modes/test/region.test.ts b/server/src/modes/test/region.test.ts
index 97cf408642..d83a08de67 100644
--- a/server/src/modes/test/region.test.ts
+++ b/server/src/modes/test/region.test.ts
@@ -86,7 +86,7 @@ function testcase(description: string) {
let content = generateContent();
const offset = content.indexOf('|');
if (offset >= 0) {
- content = content.substr(0, offset) + content.substr(offset + 1);
+ content = content.slice(0, offset) + content.slice(offset + 1);
}
const doc = TextDocument.create('test://test/test.vue', 'vue', 0, content);
diff --git a/server/src/utils/strings.ts b/server/src/utils/strings.ts
index 90d14dc802..8500ab6ae6 100644
--- a/server/src/utils/strings.ts
+++ b/server/src/utils/strings.ts
@@ -10,7 +10,7 @@ export function getWordAtText(text: string, offset: number, wordDefinition: RegE
lineStart--;
}
const offsetInLine = offset - lineStart;
- const lineText = text.substr(lineStart);
+ const lineText = text.slice(lineStart);
// make a copy of the regex as to not keep the state
const flags = wordDefinition.ignoreCase ? 'gi' : 'g';