Skip to content

Commit abe0377

Browse files
authored
[MERGE] pull request #49 from Asperguide/multiline-string-handling
Multiline string handling
2 parents 800e937 + 9280d9d commit abe0377

File tree

8 files changed

+83
-20
lines changed

8 files changed

+83
-20
lines changed

CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/).
77

8+
## [1.0.19] - 16/02/2026
9+
10+
### Fixed
11+
12+
- processing of the description entry when charage returns are provided. (comments in front of the description content are now properly prepended)
13+
- header checking (issue of a closing line being before the opening line)
14+
- header checking (grace lines (the user defined maximum scan lines added onto the current user defined scan lines) when the opening line of the header was found but not the closing one)
15+
816
## [1.0.18] - 7/02/2026
917

10-
## Added
18+
### Added
1119

1220
- language prepend option
1321
- language append option
@@ -18,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1826
- tags to make the extension easier to get discovered on the different marketplaces
1927
- GitHub Discussions for community engagement: [General Discussion](https://github.com/Asperguide/asper-header/discussions/35) and [Q&A](https://github.com/Asperguide/asper-header/discussions/36)
2028

21-
## Fixed
29+
### Fixed
2230

2331
- issue introduced in version 1.0.17 where an extra line would be added after each single comment line.
2432

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ The extension currently supports the following languages:
260260
- Fix issue where version 1.0.17 would add extra lines between single line comments in the header
261261
- Add tags to the extension to make it easier to find on the marketplaces
262262

263+
### 1.0.19
264+
265+
- Fix processing of the description entry when charage returns are provided. (comments in front of the description content are now properly prepended)
266+
- Fix header checking (issue of a closing line being before the opening line, grace lines (the user defined maximum scan lines added onto the current user defined scan lines) when the opening line of the header was found but not the closing one)
267+
263268
---
264269

265270
## Community

vscode/asperheader/CHANGELOG.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/).
77

8+
## [1.0.19] - 16/02/2026
9+
10+
### Fixed
11+
12+
- processing of the description entry when charage returns are provided. (comments in front of the description content are now properly prepended)
13+
- header checking (issue of a closing line being before the opening line)
14+
- header checking (grace lines (the user defined maximum scan lines added onto the current user defined scan lines) when the opening line of the header was found but not the closing one)
15+
816
## [1.0.18] - 7/02/2026
917

10-
## Added
18+
### Added
1119

1220
- language prepend option
1321
- language append option
@@ -18,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1826
- tags to make the extension easier to get discovered on the different marketplaces
1927
- GitHub Discussions for community engagement: [General Discussion](https://github.com/Asperguide/asper-header/discussions/35) and [Q&A](https://github.com/Asperguide/asper-header/discussions/36)
2028

21-
## Fixed
29+
### Fixed
2230

2331
- issue introduced in version 1.0.17 where an extra line would be added after each single comment line.
2432

vscode/asperheader/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ The extension currently supports the following languages:
260260
- Fix issue where version 1.0.17 would add extra lines between single line comments in the header
261261
- Add tags to the extension to make it easier to find on the marketplaces
262262

263+
### 1.0.19
264+
265+
- Fix processing of the description entry when charage returns are provided. (comments in front of the description content are now properly prepended)
266+
- Fix header checking (issue of a closing line being before the opening line, grace lines (the user defined maximum scan lines added onto the current user defined scan lines) when the opening line of the header was found but not the closing one)
267+
263268
---
264269

265270
## Community

vscode/asperheader/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vscode/asperheader/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "asperheader",
33
"displayName": "Asper Header",
44
"description": "This is an extension that will allow the developers of the Asperguide project to sign their file in an easier way and quicker",
5-
"version": "1.0.18",
5+
"version": "1.0.19",
66
"publisher": "HenryLetellier",
77
"icon": "images/icon/favicon_transparent.png",
88
"repository": {

vscode/asperheader/src/modules/commentGenerator.ts

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,20 @@ export class CommentGenerator {
345345
*/
346346
private async determineHeaderDescription(): Promise<string[]> {
347347
logger.debug(getMessage("inFunction", "determineHeaderDescription", "CommentGenerator"));
348-
let final: string[] = [];
349-
const usrProjectDescription: string = this.Config.get("projectDescription");
350-
if (usrProjectDescription.length === 0) {
348+
const rawAny = this.Config.get("projectDescription");
349+
let intermediate: string = "";
350+
if (Array.isArray(rawAny)) {
351+
intermediate = rawAny.join(this.determineNewLine(this.documentEOL || vscode.EndOfLine.LF));
352+
} else {
353+
intermediate = String(rawAny ?? "");
354+
}
355+
if (intermediate.trim().length === 0) {
351356
const usrResponse: string | undefined = await query.input(getMessage("getHeaderDescription"));
352-
final.push(usrResponse || "");
357+
intermediate = (usrResponse || "");
353358
} else {
354359
logger.debug(getMessage("configDescriptionUsed"));
355-
final.push(usrProjectDescription);
356360
}
361+
const final = intermediate.split(/\r?\n/);
357362
return final;
358363
}
359364

@@ -930,30 +935,47 @@ export class CommentGenerator {
930935
logger.warning(getMessage("closedDocument"));
931936
return undefined;
932937
}
938+
const documentTotalLines: number = this.documentBody.lineCount;
933939
const eol: vscode.EndOfLine = this.documentEOL ?? vscode.EndOfLine.LF;
934-
const opener: string = this.headerOpener(commentMiddle, eol, this.projectName);
935-
const closer: string = this.headerCloser(commentMiddle, eol, this.projectName);
936-
const scanLines: number = Math.min(this.maxScanLength, this.documentBody.lineCount);
940+
const opener: string = this.headerOpener(commentMiddle, eol, this.projectName).trimEnd();
941+
const closer: string = this.headerCloser(commentMiddle, eol, this.projectName).trimEnd();
942+
const scanLines: number = Math.min(this.maxScanLength, documentTotalLines);
943+
const graceLines: number = Math.min((this.maxScanLength * 2), documentTotalLines);
937944
let lineOpenerFound: boolean = false;
938945
let lineCloserFound: boolean = false;
939-
for (let i = 0; i < scanLines; i++) {
946+
for (let i = 0; i < scanLines || (i < graceLines && lineOpenerFound && !lineCloserFound); i++) {
940947
const lineText = this.documentBody.lineAt(i).text;
941-
if (lineText === opener.trimEnd() && lineCloserFound) {
948+
if (i >= scanLines) {
949+
logger.info(getMessage("graceLines"));
950+
}
951+
952+
// If we encounter a closer before any opener, the header is broken
953+
if (lineText === closer && !lineOpenerFound) {
942954
logger.Gui.warning(getMessage("brokenHeader"));
943955
return false;
944956
}
945-
if (lineText === closer.trimEnd() && !lineOpenerFound) {
957+
958+
// If we encounter an opener after a closer was already found, header is broken
959+
if (lineText === opener && lineCloserFound) {
946960
logger.Gui.warning(getMessage("brokenHeader"));
947961
return false;
948962
}
949-
if (lineText === opener.trimEnd() && (!lineCloserFound && !lineOpenerFound)) {
963+
964+
// Detect opener
965+
if (lineText === opener && !lineOpenerFound) {
950966
lineOpenerFound = true;
951967
this.headerInnerStart = i;
952968
logger.info(getMessage("headerOpenerFound"));
953969
continue;
954970
}
955-
if (lineText === closer.trimEnd() && (!lineCloserFound && lineOpenerFound)) {
971+
972+
// Detect closer (only valid if opener was already seen)
973+
if (lineText === closer && !lineCloserFound) {
956974
this.headerInnerEnd = i;
975+
lineCloserFound = true;
976+
}
977+
978+
if (lineCloserFound && lineOpenerFound) {
957979
logger.info(getMessage("headerOpenerAndCloserFound"));
958980
return true;
959981
}

vscode/asperheader/src/modules/messageReference.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
397397
getHeaderDescription: (): string => "Please provide a description: ",
398398
getHeaderPurpose: (): string => "Please provide the purpose of the file:",
399399
getHeaderTags: (): string => "Please enter the tags for this file, separated by commas:",
400+
graceLines: (): string => "Searching for header closer using grace lines.",
400401
headerInjectQuestion: (): string => "No header was found in this document. Would you like to add one?",
401402
headerInjectQuestionRefused: (): string => "You decided not to add the a header to the file.",
402403
headerNotFound: (): string => "No header was found in this document.",
@@ -542,6 +543,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
542543
getHeaderDescription: (): string => "Veuillez fournir une description : ",
543544
getHeaderPurpose: (): string => "Veuillez fournir l’objectif du fichier :",
544545
getHeaderTags: (): string => "Veuillez saisir les tags de ce fichier, séparés par des virgules :",
546+
graceLines: (): string => "Recherche du marqueur de fin d’en-tête en parcourant des lignes supplémentaires.",
545547
headerInjectQuestion: (): string => "Aucun en-tête trouvé dans ce document. Souhaitez-vous en ajouter un ?",
546548
headerInjectQuestionRefused: (): string => "Vous avez décidé de ne pas ajouter d'en-tête au fichier.",
547549
headerNotFound: (): string => "Aucun en-tête trouvé dans ce document.",
@@ -687,6 +689,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
687689
getHeaderDescription: (): string => "Fornisci una descrizione: ",
688690
getHeaderPurpose: (): string => "Fornisci lo scopo del file:",
689691
getHeaderTags: (): string => "Inserisci i tag per questo file, separati da virgole:",
692+
graceLines: (): string => "Ricerca del marcatore di chiusura dell'intestazione scansionando righe aggiuntive.",
690693
headerInjectQuestion: (): string => "Nessuna intestazione trovata in questo documento. Vuoi aggiungerne una?",
691694
headerInjectQuestionRefused: (): string => "Hai deciso di non aggiungere un'intestazione al file.",
692695
headerNotFound: (): string => "Nessuna intestazione trovata in questo documento.",
@@ -832,6 +835,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
832835
getHeaderDescription: (): string => "Por favor, proporciona una descripción: ",
833836
getHeaderPurpose: (): string => "Proporcione el propósito del archivo:",
834837
getHeaderTags: (): string => "Ingrese las etiquetas para este archivo, separadas por comas:",
838+
graceLines: (): string => "Buscando el marcador de cierre del encabezado escaneando líneas adicionales.",
835839
headerInjectQuestion: (): string => "No se encontró encabezado en este documento. ¿Desea agregar uno?",
836840
headerInjectQuestionRefused: (): string => "Decidió no agregar un encabezado al archivo.",
837841
headerNotFound: (): string => "No se encontró encabezado en este documento.",
@@ -977,6 +981,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
977981
getHeaderDescription: () => "Bitte Beschreibung angeben:",
978982
getHeaderPurpose: () => "Bitte Zweck der Datei angeben:",
979983
getHeaderTags: () => "Bitte Tags für diese Datei eingeben, durch Kommas getrennt:",
984+
graceLines: (): string => "Suche nach dem Header-Schlusszeichen, scanne zusätzliche Zeilen.",
980985
headerInjectQuestion: () => "Kein Header gefunden. Möchten Sie einen hinzufügen?",
981986
headerInjectQuestionRefused: () => "Sie haben entschieden, keinen Header hinzuzufügen.",
982987
headerNotFound: () => "Kein Header in diesem Dokument gefunden.",
@@ -1122,6 +1127,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
11221127
getHeaderDescription: () => "説明を入力してください: ",
11231128
getHeaderPurpose: () => "ファイルの目的を入力してください: ",
11241129
getHeaderTags: () => "このファイルのタグをカンマで区切って入力してください: ",
1130+
graceLines: (): string => "ヘッダーの終了マーカーを探索するために追加の行を走査しています。",
11251131
headerInjectQuestion: () => "このドキュメントにヘッダーが見つかりません。追加しますか?",
11261132
headerInjectQuestionRefused: () => "ファイルにヘッダーを追加しないことにしました。",
11271133
headerNotFound: () => "このドキュメントにヘッダーが見つかりません。",
@@ -1267,6 +1273,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
12671273
getHeaderDescription: () => "설명을 입력하세요: ",
12681274
getHeaderPurpose: () => "파일의 목적을 입력하세요: ",
12691275
getHeaderTags: () => "이 파일의 태그를 쉼표로 구분하여 입력하세요: ",
1276+
graceLines: (): string => "추가 행을 스캔하여 헤더 종료를 검색합니다.",
12701277
headerInjectQuestion: () => "이 문서에서 헤더를 찾을 수 없습니다. 추가하시겠습니까?",
12711278
headerInjectQuestionRefused: () => "파일에 헤더를 추가하지 않기로 결정했습니다.",
12721279
headerNotFound: () => "이 문서에서 헤더를 찾을 수 없습니다.",
@@ -1412,6 +1419,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
14121419
getHeaderDescription: () => "Пожалуйста, предоставьте описание: ",
14131420
getHeaderPurpose: () => "Пожалуйста, укажите назначение файла: ",
14141421
getHeaderTags: () => "Введите теги для этого файла через запятую: ",
1422+
graceLines: (): string => "Поиск конца заголовка, сканирование дополнительных строк.",
14151423
headerInjectQuestion: () => "Заголовок в этом документе не найден. Хотите добавить его?",
14161424
headerInjectQuestionRefused: () => "Вы решили не добавлять заголовок в файл.",
14171425
headerNotFound: () => "Заголовок в этом документе не найден.",
@@ -1557,6 +1565,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
15571565
getHeaderDescription: () => "Por favor, forneça uma descrição: ",
15581566
getHeaderPurpose: () => "Por favor, forneça o propósito do arquivo:",
15591567
getHeaderTags: () => "Digite as tags para este arquivo, separadas por vírgulas:",
1568+
graceLines: (): string => "Procurando o marcador de fechamento do cabeçalho examinando linhas adicionais.",
15601569
headerInjectQuestion: () => "Nenhum cabeçalho encontrado neste documento. Deseja adicionar um?",
15611570
headerInjectQuestionRefused: () => "Você optou por não adicionar um cabeçalho ao arquivo.",
15621571
headerNotFound: () => "Nenhum cabeçalho encontrado neste documento.",
@@ -1702,6 +1711,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
17021711
getHeaderDescription: () => "Lütfen bir açıklama sağlayın: ",
17031712
getHeaderPurpose: () => "Lütfen dosyanın amacını belirtin:",
17041713
getHeaderTags: () => "Bu dosya için etiketleri virgülle ayırarak girin:",
1714+
graceLines: (): string => "Başlık kapanış işaretini bulmak için ek satırlar taranıyor.",
17051715
headerInjectQuestion: () => "Bu belgede başlık bulunamadı. Eklemek ister misiniz?",
17061716
headerInjectQuestionRefused: () => "Dosyaya başlık eklememeyi seçtiniz.",
17071717
headerNotFound: () => "Bu belgede başlık bulunamadı.",
@@ -1847,6 +1857,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
18471857
getHeaderDescription: () => "Podaj opis: ",
18481858
getHeaderPurpose: () => "Podaj cel pliku:",
18491859
getHeaderTags: () => "Wprowadź tagi dla tego pliku, oddzielone przecinkami:",
1860+
graceLines: (): string => "Wyszukiwanie znacznika końca nagłówka, skanuję dodatkowe wiersze.",
18501861
headerInjectQuestion: () => "Nie znaleziono nagłówka w tym dokumencie. Czy chcesz dodać jeden?",
18511862
headerInjectQuestionRefused: () => "Zdecydowano nie dodawać nagłówka do pliku.",
18521863
headerNotFound: () => "Nie znaleziono nagłówka w tym dokumencie.",
@@ -1992,6 +2003,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
19922003
getHeaderDescription: () => "Zadejte popis: ",
19932004
getHeaderPurpose: () => "Zadejte účel souboru:",
19942005
getHeaderTags: () => "Zadejte tagy pro tento soubor, oddělené čárkou:",
2006+
graceLines: (): string => "Hledání ukončovací značky hlavičky skenováním dalších řádků.",
19952007
headerInjectQuestion: () => "V tomto dokumentu nebyla nalezena žádná hlavička. Chcete ji přidat?",
19962008
headerInjectQuestionRefused: () => "Rozhodli jste se nepřidávat hlavičku do souboru.",
19972009
headerNotFound: () => "V tomto dokumentu nebyla nalezena žádná hlavička.",
@@ -2137,6 +2149,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
21372149
getHeaderDescription: () => "Adjon meg egy leírást: ",
21382150
getHeaderPurpose: () => "Adja meg a fájl célját:",
21392151
getHeaderTags: () => "Adja meg a fájl címkéit, vesszővel elválasztva:",
2152+
graceLines: (): string => "Fejléc lezáró jelének keresése további sorok átvizsgálásával.",
21402153
headerInjectQuestion: () => "Nem található fejléc ebben a dokumentumban. Szeretne hozzáadni egyet?",
21412154
headerInjectQuestionRefused: () => "Úgy döntött, hogy nem ad hozzá fejlécet a fájlhoz.",
21422155
headerNotFound: () => "Nem található fejléc ebben a dokumentumban.",
@@ -2282,6 +2295,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
22822295
getHeaderDescription: () => "请输入描述:",
22832296
getHeaderPurpose: () => "请输入文件用途:",
22842297
getHeaderTags: () => "请输入文件标签,用逗号分隔:",
2298+
graceLines: (): string => "使用宽限行搜索头部结束标记。",
22852299
headerInjectQuestion: () => "未找到头部。是否添加一个?",
22862300
headerInjectQuestionRefused: () => "您选择不向文件添加头部。",
22872301
headerNotFound: () => "未找到头部。",
@@ -2427,6 +2441,7 @@ export const messages: Record<string, Record<string, (...args: any[]) => string>
24272441
getHeaderDescription: () => "請提供描述:",
24282442
getHeaderPurpose: () => "請提供檔案用途:",
24292443
getHeaderTags: () => "請輸入檔案標籤,用逗號分隔:",
2444+
graceLines: (): string => "使用寬限行搜尋標頭結束標記。",
24302445
headerInjectQuestion: () => "未找到頭部。是否添加一個?",
24312446
headerInjectQuestionRefused: () => "您選擇不向檔案添加頭部。",
24322447
headerNotFound: () => "未找到頭部。",

0 commit comments

Comments
 (0)