Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义信息和版权信息前出现多余字段 #296

Closed
SJ2050cn opened this issue Mar 3, 2021 · 15 comments
Closed

自定义信息和版权信息前出现多余字段 #296

SJ2050cn opened this issue Mar 3, 2021 · 15 comments

Comments

@SJ2050cn
Copy link

SJ2050cn commented Mar 3, 2021

注意:

  1. 可以先试一下常见问题中的方法.
  2. 然后搜一搜以前关闭的issue看有没有相似的问题可以帮助解决问题。
  3. 打开fileheader.configObj.showErrorMessage看看没有没有报错信息
  4. issue提的越清晰,越容易定位问题/找到bug,越快速的解决问题。

描述bug(必填)
自定义信息和版权信息前出现其他字段,更新后才有,之前的老版本没这个问题。

注释设置(必填):

VsCode设置:

        // 头部注释默认字段
        "Author": "SJ2050",
        "Date": "Do not edit", // 设置后默认设置文件生成时间
        "LastEditTime": "Do not edit", // 设置后,保存文件更改默认更新最后编辑时间
        "custom_string_obkoro1": "Version: ",
        "Description": "",
        "custom_string_obkoro1_copyright": "Copyright © ${now_year} SJ2050",
    },
    // 函数注释
    "fileheader.cursorMode": {
        // 默认字段
        "description":"",
        "param":"",
        "return":""
    },

文件后缀(必填):

如:test.js 的后缀为 js

你得到的注释(必填):

你生成的注释为:

预期的行为(必填):

预期得到的注释/行为:

错误日志(选填):

怎么生成错误日志?

屏幕截图(选填)

image-20210303160047414
问题相关(选填)
在这里添加关于这个问题的任何其他上下文。

@OBKoro1
Copy link
Owner

OBKoro1 commented Mar 4, 2021

加下我的微信 我详细了解一下情况:OBKoro1

@ShaneTian
Copy link

遇到相同问题,请问如何解决?

@OBKoro1
Copy link
Owner

OBKoro1 commented Mar 16, 2021

@ShaneTian 加下我的微信 我详细了解一下情况:OBKoro1

@ShaneTian
Copy link

@ShaneTian 加下我的微信 我详细了解一下情况:OBKoro1

需要了解什么?

@Jieli12
Copy link

Jieli12 commented Mar 18, 2021

我也遇到同样的问题:
我的设置如下:
Screenshot 2021-03-18 at 13 42 55

出来的结果是:
Screenshot 2021-03-18 at 13 42 13
我的设置是根据,下图配置的:
Screenshot 2021-03-18 at 13 44 25
@OBKoro1 ,请问每次版本迭代,配置文档中的字段名称也同时更新了吗?

有一个临时解决方案:
在 4.82 版本以前(包括 4.8.2),我用下面的设置,是正常显示的。
Screenshot 2021-03-18 at 13 53 28

也就是把版权字段改成"custom_string_obkoro10001",注意我在 4.8.2 版本中这样做是正常的。我查了一下作者是用这个作为版权字段的,新版本中可能已经改了。这个方法在 4.8.3 中同样不起作用。希望作者及时改正这个 issue。同时感谢作者辛苦开发,让写代码轻松了很多。

@OBKoro1
Copy link
Owner

OBKoro1 commented Mar 19, 2021

  1. 请问是window系统吗 mac 这边是好的
  2. 打开fileheader.configObj.showErrorMessage看看没有没有报错信息?
  3. 文件后缀是什么?

@ShaneTian
Copy link

ShaneTian commented Mar 19, 2021

  1. Mac 系统
  2. 已打开,未发现报错信息
  3. 文件后缀为 .py.sh 不会产生多余字段
  4. 整体配置如下:
    image
  5. 多余字段如下:
    image

@OBKoro1
Copy link
Owner

OBKoro1 commented Mar 19, 2021

customMade 确实有问题,周末会修复它。
其他人好像不是customMade里面配置的,建议将配置截图 截全点。

@Jieli12
Copy link

Jieli12 commented Mar 19, 2021

�我的是 Mac系统,后缀文件名是 .m ,我是在customMade里面配置的, 好像所有人都是在 customMade里面配置的, 请仔细阅读,否则也不会来这里反映问题。

@OBKoro1
Copy link
Owner

OBKoro1 commented Mar 22, 2021

@Jieli12 其他配置和文件内容截图发一下 截图截全点 我看能不能找到问题。

@OBKoro1
Copy link
Owner

OBKoro1 commented Mar 22, 2021

函数注释的bug 我已经修复了。

@helianvine
Copy link

函数注释的bug 我已经修复了。

似乎还是有问题

版本:4.8.4

文件类型:.c和.h

配置内容:
"fileheader.customMade": {
"custom_string_obkoro1_date": "Do not edit", // 不带Date前缀的时间
"Github": "https://github.com/OBKoro1",
"custom_string_obkoro2": "custom_string_obkoro1~custom_string_obkoro100都可以输出自定义信息",
"Author": "OBKoro1",
"custom_string_obkoro1_copyright": "Copyright ${now_year} OBKoro1", // 版权声明 自动替换年份
"custom_string_obkoro1": "可以输入预定的版权声明、个性签名、空行等"
}

输出
/*

  • symbol_custom_string_obkoro10000: 2021-03-23
  • Github : https://github.com/OBKoro1
  • symbol_custom_string_obkoro2: custom_string_obkoro1~custom_string_obkoro100都可以输出自定义信息
  • Author : OBKoro1
  • symbol_custom_string_obkoro10001: Copyright 2021 OBKoro1
  • symbol_custom_string_obkoro1: 可以输入预定的版权声明、个性签名、空行等

@OBKoro1
Copy link
Owner

OBKoro1 commented Mar 23, 2021

@helianvine 可以加下微信 排查一下吗 微信:OBKoro1

@Jieli12
Copy link

Jieli12 commented Mar 23, 2021

@Jieli12 其他配置和文件内容截图发一下 截图截全点 我看能不能找到问题。

@OBKoro1 感谢你的工作,很不幸,问题依然存在. 下面的是我的详细配置信息(Mac OS):
"fileheader.customMade": {
"Author": "Jie Li",
"Date": "Do not edit",
"LastEditTime": "Do not edit",
"LastEditors": "Jie Li",
"FilePath": "Do not edit",
"Description": "\r\n\n\n\n\n\n",
"custom_string_obkoro1_copyright": "Copyright (c) ${now_year} by Jie Li, \nAll Rights Reserved. " // 版权声明 自动替换年份
// "License": "MIT"
},
// 函数注释
"fileheader.cursorMode": {
// 默认字段
"description": "",
"param": "",
"return": ""
},
"fileheader.configObj": {
"createFileTime": true,
"language": {
"m": {
"head": "%%",
"middle": "% ",
"end": "%%"
},
"h/hpp/cpp": {
"head": "/*** ", // 统一增加几个
"middle": "
",
"end": "/"
},
"r": {
"head": "#### ", // 统一增加几个

"middle": "# ",
"end": "####"
},
"tex/latex/bib": {
"head": "% ", // 统一增加几个

"middle": "% ",
"end": "%"
},
"md/mdwn": {
"head": ""
},
"py": {
"head": "# ", // 统一增加几个

"middle": "# ",
"end": "#"
}
},
"autoAdd": true,
"autoAddLine": 100,
"autoAlready": true,
"annotationStr": {
"head": "/*",
"middle": " * @",
"end": " /",
"use": false
},
"headInsertLine": {
"php": 2, // php后缀的文件,在第二行插入文件头部注释
// "
": 3, // 所有文件都在第3行插入注释(除了php)
},
"beforeAnnotation": {
"文件后缀": "该文件后缀的头部注释之前添加某些内容"
},
"afterAnnotation": {
"文件后缀": "该文件后缀的头部注释之后添加某些内容"
},
"specialOptions": {
"Date": "Date",
"FilePath": "File Path",
"LastEditTime": "Last Revision",
"LastEditors": "Last Author",
"Description": "Description",
"License": "MIT"
},
"switch": {
"newlineAddAnnotation": true
},
"supportAutoLanguage": [],
"prohibitAutoAdd": [
"json",
"md",
"mdwn"
],
"prohibitItemAutoAdd": [
"项目的全称, 整个项目禁止自动添加头部注释, 可以使用快捷键添加"
],
"moveCursor": true,
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"atSymbol": "@",
"atSymbolObj": {
"文件后缀": "修改它的@符号"
},
"colon": ": ",
"colonObj": {
"文件后缀": "修改它的冒号"
},
"filePathColon": "路径分隔符替换",
"showErrorMessage": true,
"wideSame": true,
"wideNum": 15,
"CheckFileChange": true,
"createHeader": true,
"useWorker": false,
"typeParam": true,
"designAddHead": false,
"headDesignName": "random",
"headDesign": false
},
以上配置都是 follow https://github.com/OBKoro1/koro1FileHeader/wiki 里的介绍。(很久以前配置的,可能跟最近的配置不一样,抱歉我没有仔细检查)。
在 4.8.4版本下,我检查了“showErrorMessage”, 结果如下:
Screenshot 2021-03-23 at 13 02 54
希望能帮你找到问题所在。

P.S.
我查了一下,问题出现在这行(第 40 行):console.error(toErrorMessage(e.item.message.linkedText.toString(), true)); 下面是整个notificationsAlerts.ts 文件:
/*---------------------------------------------------------------------------------------------

  • Copyright (c) Microsoft Corporation. All rights reserved.
  • Licensed under the MIT License. See License.txt in the project root for license information.
    --------------------------------------------------------------------------------------------/

import { alert } from 'vs/base/browser/ui/aria/aria';
import { localize } from 'vs/nls';
import { INotificationViewItem, INotificationsModel, NotificationChangeType, INotificationChangeEvent, NotificationViewItemContentChangeKind } from 'vs/workbench/common/notifications';
import { Disposable } from 'vs/base/common/lifecycle';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import { Severity } from 'vs/platform/notification/common/notification';
import { Event } from 'vs/base/common/event';

export class NotificationsAlerts extends Disposable {

constructor(private readonly model: INotificationsModel) {
	super();

	// Alert initial notifications if any
	model.notifications.forEach(n => this.triggerAriaAlert(n));

	this.registerListeners();
}

private registerListeners(): void {
	this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
}

private onDidChangeNotification(e: INotificationChangeEvent): void {
	if (e.kind === NotificationChangeType.ADD) {

		// ARIA alert for screen readers
		this.triggerAriaAlert(e.item);

		// Always log errors to console with full details
		if (e.item.severity === Severity.Error) {
			if (e.item.message.original instanceof Error) {
				console.error(e.item.message.original);
			} else {
				console.error(toErrorMessage(e.item.message.linkedText.toString(), true));
			}
		}
	}
}

private triggerAriaAlert(notifiation: INotificationViewItem): void {
	if (notifiation.silent) {
		return;
	}

	// Trigger the alert again whenever the message changes
	const listener = notifiation.onDidChangeContent(e => {
		if (e.kind === NotificationViewItemContentChangeKind.MESSAGE) {
			this.doTriggerAriaAlert(notifiation);
		}
	});

	Event.once(notifiation.onDidClose)(() => listener.dispose());

	this.doTriggerAriaAlert(notifiation);
}

private doTriggerAriaAlert(notifiation: INotificationViewItem): void {
	let alertText: string;
	if (notifiation.severity === Severity.Error) {
		alertText = localize('alertErrorMessage', "Error: {0}", notifiation.message.linkedText.toString());
	} else if (notifiation.severity === Severity.Warning) {
		alertText = localize('alertWarningMessage', "Warning: {0}", notifiation.message.linkedText.toString());
	} else {
		alertText = localize('alertInfoMessage', "Info: {0}", notifiation.message.linkedText.toString());
	}

	alert(alertText);
}

}

@OBKoro1
Copy link
Owner

OBKoro1 commented Mar 29, 2021

@Jieli12 更新插件,该bug已修复。
觉得插件还不错的话,就给我点个Star吧~

@OBKoro1 OBKoro1 closed this as completed Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants