Skip to content

Commit

Permalink
feat: ✨add pathContainsWorkspaceFolder setting
Browse files Browse the repository at this point in the history
  • Loading branch information
hks2002 committed Mar 10, 2023
1 parent eb7da7a commit 9bab7bf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
"default": "YYYY-MM-DD HH:mm:ss",
"description": "%auto-header-plus.dateFormat%"
},
"auto-header-plus.pathContainsWorkspaceFolder": {
"order": 4,
"type": "boolean",
"default": true,
"description": "%auto-header-plus.pathContainsWorkspaceFolder%"
},
"auto-header-plus.commandTimesout": {
"order": 5,
"type": "integer",
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"auto-header-plus.lineWidth": "Line width, include the start and end, set to `0` to disable",
"auto-header-plus.middleLineEnd": "Middle line end string",
"auto-header-plus.middleLineStart": "Middle line start string",
"auto-header-plus.commandTimesout": "Command timeout, unit: ms"
"auto-header-plus.commandTimesout": "Command timeout, unit: ms",
"auto-header-plus.pathContainsWorkspaceFolder": "Path contains workspace folder name, disable it if your file path is too long, such as java maven project, only works in `RELATIVEPATH`"
}
3 changes: 2 additions & 1 deletion package.nls.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"auto-header-plus.lineWidth": "行宽度, 包括开始和结束, 如果值为0, 则不会自动填充",
"auto-header-plus.middleLineEnd": "中间行结束字符串",
"auto-header-plus.middleLineStart": "中间行开始字符串",
"auto-header-plus.commandTimesout": "命令超时时间, 单位: ms"
"auto-header-plus.commandTimesout": "命令超时时间, 单位: ms",
"auto-header-plus.pathContainsWorkspaceFolder": "路径是否包含项目工作区文件夹,如果你的文件路径太长,可以关闭它,例如java maven项目,仅在`RELATIVEPATH`中生效"
}
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author : Robert Huang<56649783@qq.com> *
* @CreatedDate : 2023-02-04 20:40:57 *
* @LastEditors : Robert Huang<56649783@qq.com> *
* @LastEditDate : 2023-03-10 16:36:06 *
* @LastEditDate : 2023-03-10 16:41:14 *
* @FilePath : auto-header-plus/src/utils.ts *
* @CopyRight : MerBleueAviation *
*****************************************************************************/
Expand Down Expand Up @@ -193,7 +193,7 @@ const getPathValue = (key: string, uri: vscode.Uri): string => {
case 'FULLPATH':
return uri?.fsPath.replace(/\\/g, '/') || ''
case 'RELATIVEPATH': {
return vscode.workspace.asRelativePath(uri, true).replace(/\\/g, '/') || ''
return config().get("pathContainsWorkspaceFolder") ? vscode.workspace.asRelativePath(uri, true).replace(/\\/g, '/') || '' : vscode.workspace.asRelativePath(uri, false).replace(/\\/g, '/') || ''
}
case 'SHORTNAMEPATH':
return path.basename(uri?.fsPath.replace(/\\/g, '/')) || ''
Expand Down

0 comments on commit 9bab7bf

Please sign in to comment.