Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Commands support placeholders similar to tasks.json.
* ${fileDirname}: directory name of tracking file
* ${fileExtname}: extension (including .) of tracking file
* ${fileBasenameNoExt}: tracking file's basename without extension
* ${fileBasenameNoExtAll}: tracking file's basename without all extensions

Samples
=========
Expand Down
12 changes: 12 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import * as vscode from "vscode";
import * as path from "path";
import { ICmdReplaceInfo, IColors, IDocumentUriMap } from "./types";

function fileBasenameNoExtAll(fsPath, extName) {
while (fsPath.includes('.') === true) {
extName = path.extname(fsPath);
fsPath = path.basename(fsPath, extName);
}
return fsPath;
}

function getCmdReplaceInfo(
documentUri: vscode.Uri,
documentOldUri?: vscode.Uri
Expand Down Expand Up @@ -49,6 +57,10 @@ function getCmdReplaceInfo(
pattern: /\${fileBasenameNoExt}/,
replaceStr: path.basename(fsPath, extName),
},
{
pattern: /\${fileBasenameNoExtAll}/,
replaceStr: fileBasenameNoExtAll(fsPath, extName),
}
];
}

Expand Down