Incidencia #40266

SortAscending, SortDescending での改行の扱いを修正

Abrir Fecha: 2020-03-19 16:13 Última actualización: 2020-04-29 10:02

Informador:
(Anónimo)
Propietario:
(Ninguno)
Tipo:
Estado:
Cerrado
Componente:
(Ninguno)
Hito:
(Ninguno)
Prioridad:
4
Gravedad:
5 - Medium
Resolución:
Fixed
Fichero:
Ninguno

Details

editor addin.sct で、昇順ソート・降順ソートの実行時、CRLFの途中で分割されていたのを修正してみました。

  • 文字列が「\n」で分割されていたのを、「\r\n」で分割するように修正
  • 選択範囲の末尾が改行まで含んでいるか、改行の手前までを選択しているかで挙動が異なっていたのを修正


  1. function SortAscending(Text) {
  2. var lines = Text.split("\r\n");
  3. if (lines.length == 1) {
  4. return Text;
  5. } else if (lines[lines.length - 1] == "") {
  6. lines.pop();
  7. return lines.sort().join("\r\n") + "\r\n";
  8. } else {
  9. return lines.sort().join("\r\n");
  10. }
  11. }
  12. function SortDescending(Text) {
  13. var lines = Text.split("\r\n");
  14. if (lines.length == 1) {
  15. return Text;
  16. } else if (lines[lines.length - 1] == "") {
  17. lines.pop();
  18. lines.sort(function(a, b) { return a < b ? 1 : -1; });
  19. return lines.join("\r\n") + "\r\n";
  20. } else {
  21. return lines.sort(function(a, b) { return a < b ? 1 : -1; }).join("\r\n");
  22. }
  23. }

Ticket History (3/5 Histories)

2020-03-19 16:13 Updated by: None
  • New Ticket "SortAscending, SortDescending での改行の扱いを修正" created
2020-03-20 00:22 Updated by: None
Comentario

修正ありがとうございます。

var lines = Text.split("\r\n"); だと 改行文字がUnixタイプのファイル("\n"のみ)の場合にうまくいかないように思いますので、若干変更して取り込ませていただきます。

2020-03-23 11:34 Updated by: None
Comentario

Reply To (Anonymous)

修正ありがとうございます。 var lines = Text.split("\r\n"); だと 改行文字がUnixタイプのファイル("\n"のみ)の場合にうまくいかないように思いますので、若干変更して取り込ませていただきます。


お手数おかけします。
SortDescending で区切りが "\r\n" のままになっているようです。

  1. function SortDescending(Text) {
  2. var eol = Text.match(/\r\n|\n|\r/);
  3. var lines = Text.split("\r\n"); //←←←
  4. //………
  5. }

2020-03-24 07:17 Updated by: None
Comentario

ありがとうございます。修正します。

2020-04-29 10:02 Updated by: sdottaka
  • Resolución Update from Ninguno to Fixed
  • Estado Update from Open to Cerrado

Attachment File List

No attachments

Editar

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Entrar