From 3f8a55b32c494288c3b1b4bb7c8e26cf1d899fad Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 16 Aug 2023 11:11:20 -0700 Subject: [PATCH] `trimLeft` -> `trimStart` (#190601) These should be the same but the `trimLeft` name has been deprecated --- extensions/git/src/git.ts | 4 ++-- .../contrib/linesOperations/browser/moveLinesCommand.ts | 8 ++++---- src/vs/workbench/contrib/search/browser/searchModel.ts | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index ab03a354d11..62bdf24ebcb 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -481,7 +481,7 @@ export class Git { const result = await this.exec(pathInsidePossibleRepository, ['rev-parse', '--show-toplevel']); // Keep trailing spaces which are part of the directory name - const repositoryRootPath = path.normalize(result.stdout.trimLeft().replace(/[\r\n]+$/, '')); + const repositoryRootPath = path.normalize(result.stdout.trimStart().replace(/[\r\n]+$/, '')); if (isWindows) { // On Git 2.25+ if you call `rev-parse --show-toplevel` on a mapped drive, instead of getting the mapped @@ -528,7 +528,7 @@ export class Git { !isDescendant(pathInsidePossibleRepository, repositoryRootPath) && this.compareGitVersionTo('2.31.0') !== -1) { const relativePathResult = await this.exec(pathInsidePossibleRepository, ['rev-parse', '--path-format=relative', '--show-toplevel',]); - return path.resolve(pathInsidePossibleRepository, relativePathResult.stdout.trimLeft().replace(/[\r\n]+$/, '')); + return path.resolve(pathInsidePossibleRepository, relativePathResult.stdout.trimStart().replace(/[\r\n]+$/, '')); } return repositoryRootPath; diff --git a/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts b/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts index 6193ce53e26..8db880a15ad 100644 --- a/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts +++ b/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts @@ -117,7 +117,7 @@ export class MoveLinesCommand implements ICommand { const oldIndentation = strings.getLeadingWhitespace(model.getLineContent(movingLineNumber)); const newSpaceCnt = movingLineMatchResult + indentUtils.getSpaceCnt(oldIndentation, tabSize); const newIndentation = indentUtils.generateIndent(newSpaceCnt, tabSize, insertSpaces); - insertingText = newIndentation + this.trimLeft(movingLineText); + insertingText = newIndentation + this.trimStart(movingLineText); } else { // no enter rule matches, let's check indentatin rules then. virtualModel.getLineContent = (lineNumber: number) => { @@ -141,7 +141,7 @@ export class MoveLinesCommand implements ICommand { const oldSpaceCnt = indentUtils.getSpaceCnt(oldIndentation, tabSize); if (newSpaceCnt !== oldSpaceCnt) { const newIndentation = indentUtils.generateIndent(newSpaceCnt, tabSize, insertSpaces); - insertingText = newIndentation + this.trimLeft(movingLineText); + insertingText = newIndentation + this.trimStart(movingLineText); } } } @@ -272,7 +272,7 @@ export class MoveLinesCommand implements ICommand { enterPrefix = indentConverter.unshiftIndent(enter.indentation) + enter.appendText; } const movingLineText = model.getLineContent(line); - if (this.trimLeft(movingLineText).indexOf(this.trimLeft(enterPrefix)) >= 0) { + if (this.trimStart(movingLineText).indexOf(this.trimStart(enterPrefix)) >= 0) { const oldIndentation = strings.getLeadingWhitespace(model.getLineContent(line)); let newIndentation = strings.getLeadingWhitespace(enterPrefix); const indentMetadataOfMovelingLine = getIndentMetadata(model, line, this._languageConfigurationService); @@ -354,7 +354,7 @@ export class MoveLinesCommand implements ICommand { return this.parseEnterResult(model, indentConverter, tabSize, line, enter); } - private trimLeft(str: string) { + private trimStart(str: string) { return str.replace(/^\s+/, ''); } diff --git a/src/vs/workbench/contrib/search/browser/searchModel.ts b/src/vs/workbench/contrib/search/browser/searchModel.ts index 81920160a6c..8f9dd5cdcb6 100644 --- a/src/vs/workbench/contrib/search/browser/searchModel.ts +++ b/src/vs/workbench/contrib/search/browser/searchModel.ts @@ -94,7 +94,7 @@ export class Match { after = this._oneLinePreviewText.substring(this._rangeInPreviewText.endColumn - 1); before = lcut(before, 26); - before = before.trimLeft(); + before = before.trimStart(); let charsRemaining = Match.MAX_PREVIEW_CHARS - before.length; inside = inside.substr(0, charsRemaining);