#31627
snow
Participant

コメントはエディタの持つ「状態」ではなく、その場で調べて判断しているため、「今どっちか」が取れないということかも知れませんね。
ちょっと考えてみたのですが、行全体を選択しないパターンの「コメント解除」がうまく行っていません。
「コメント」後の選択範囲を見ると、コメント開始は含まれず、コメント終了は含まれているので、元々ちょっと特殊ですね。

function startsWith(a, b) {
	return b && a.substring(0, b.length) == b;
}
function endsWith(a, b) {
	return a.substring(a.length - b.length) == b;
}
function trim(a) {
	return a.replace(/^[\s]+|[\s]$/g, '');
}
var t = document.selection.Text;
if (!t) {
	document.selection.SelectLine();
	t = document.selection.Text;
}
trim(t);
var h = document.Config.Highlight;
var f = startsWith(t, h.LineComment1) || startsWith(t, h.LineComment2);
if (!f) {
	startsWith(t, h.CommentBegin) && endsWith(t, h.CommentEnd);
}
editor.ExecuteCommandByID(f ? 4372 : 4371);