From 5d6dd97baaf9bfe13338f4161e09fd88a73977ca Mon Sep 17 00:00:00 2001 From: Henry LETELLIER Date: Mon, 16 Feb 2026 12:19:04 +0100 Subject: [PATCH 1/3] [UPDATE] the description to handle multiline inputs properly. --- vscode/asperheader/package.json | 2 +- .../asperheader/src/modules/commentGenerator.ts | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/vscode/asperheader/package.json b/vscode/asperheader/package.json index b2dc073..49a0e82 100644 --- a/vscode/asperheader/package.json +++ b/vscode/asperheader/package.json @@ -2,7 +2,7 @@ "name": "asperheader", "displayName": "Asper Header", "description": "This is an extension that will allow the developers of the Asperguide project to sign their file in an easier way and quicker", - "version": "1.0.18", + "version": "1.0.19", "publisher": "HenryLetellier", "icon": "images/icon/favicon_transparent.png", "repository": { diff --git a/vscode/asperheader/src/modules/commentGenerator.ts b/vscode/asperheader/src/modules/commentGenerator.ts index deed38d..093890f 100644 --- a/vscode/asperheader/src/modules/commentGenerator.ts +++ b/vscode/asperheader/src/modules/commentGenerator.ts @@ -345,15 +345,20 @@ export class CommentGenerator { */ private async determineHeaderDescription(): Promise { logger.debug(getMessage("inFunction", "determineHeaderDescription", "CommentGenerator")); - let final: string[] = []; - const usrProjectDescription: string = this.Config.get("projectDescription"); - if (usrProjectDescription.length === 0) { + const rawAny = this.Config.get("projectDescription"); + let intermediate: string = ""; + if (Array.isArray(rawAny)) { + intermediate = rawAny.join(this.determineNewLine(this.documentEOL || vscode.EndOfLine.LF)); + } else { + intermediate = String(rawAny ?? ""); + } + if (intermediate.trim().length === 0) { const usrResponse: string | undefined = await query.input(getMessage("getHeaderDescription")); - final.push(usrResponse || ""); + intermediate = (usrResponse || ""); } else { logger.debug(getMessage("configDescriptionUsed")); - final.push(usrProjectDescription); } + const final = intermediate.split(/\r?\n/); return final; } From 8a72d642a81e635e782cf464d2b2baee35edf11c Mon Sep 17 00:00:00 2001 From: Henry LETELLIER Date: Mon, 16 Feb 2026 13:06:00 +0100 Subject: [PATCH 2/3] [FIX] check when the closing line appears before the opening line --- vscode/asperheader/package-lock.json | 4 +-- .../src/modules/commentGenerator.ts | 33 ++++++++++++++----- .../src/modules/messageReference.ts | 15 +++++++++ 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/vscode/asperheader/package-lock.json b/vscode/asperheader/package-lock.json index e35f4d0..9e42eb6 100644 --- a/vscode/asperheader/package-lock.json +++ b/vscode/asperheader/package-lock.json @@ -1,12 +1,12 @@ { "name": "asperheader", - "version": "1.0.18", + "version": "1.0.19", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "asperheader", - "version": "1.0.18", + "version": "1.0.19", "dependencies": { "jsonc-parser": "^3.3.1" }, diff --git a/vscode/asperheader/src/modules/commentGenerator.ts b/vscode/asperheader/src/modules/commentGenerator.ts index 093890f..92379a9 100644 --- a/vscode/asperheader/src/modules/commentGenerator.ts +++ b/vscode/asperheader/src/modules/commentGenerator.ts @@ -935,30 +935,47 @@ export class CommentGenerator { logger.warning(getMessage("closedDocument")); return undefined; } + const documentTotalLines: number = this.documentBody.lineCount; const eol: vscode.EndOfLine = this.documentEOL ?? vscode.EndOfLine.LF; - const opener: string = this.headerOpener(commentMiddle, eol, this.projectName); - const closer: string = this.headerCloser(commentMiddle, eol, this.projectName); - const scanLines: number = Math.min(this.maxScanLength, this.documentBody.lineCount); + const opener: string = this.headerOpener(commentMiddle, eol, this.projectName).trimEnd(); + const closer: string = this.headerCloser(commentMiddle, eol, this.projectName).trimEnd(); + const scanLines: number = Math.min(this.maxScanLength, documentTotalLines); + const graceLines: number = Math.min((this.maxScanLength * 2), documentTotalLines); let lineOpenerFound: boolean = false; let lineCloserFound: boolean = false; - for (let i = 0; i < scanLines; i++) { + for (let i = 0; i < scanLines || (i < graceLines && lineOpenerFound && !lineCloserFound); i++) { const lineText = this.documentBody.lineAt(i).text; - if (lineText === opener.trimEnd() && lineCloserFound) { + if (i >= scanLines) { + logger.info(getMessage("graceLines")); + } + + // If we encounter a closer before any opener, the header is broken + if (lineText === closer && !lineOpenerFound) { logger.Gui.warning(getMessage("brokenHeader")); return false; } - if (lineText === closer.trimEnd() && !lineOpenerFound) { + + // If we encounter an opener after a closer was already found, header is broken + if (lineText === opener && lineCloserFound) { logger.Gui.warning(getMessage("brokenHeader")); return false; } - if (lineText === opener.trimEnd() && (!lineCloserFound && !lineOpenerFound)) { + + // Detect opener + if (lineText === opener && !lineOpenerFound) { lineOpenerFound = true; this.headerInnerStart = i; logger.info(getMessage("headerOpenerFound")); continue; } - if (lineText === closer.trimEnd() && (!lineCloserFound && lineOpenerFound)) { + + // Detect closer (only valid if opener was already seen) + if (lineText === closer && !lineCloserFound) { this.headerInnerEnd = i; + lineCloserFound = true; + } + + if (lineCloserFound && lineOpenerFound) { logger.info(getMessage("headerOpenerAndCloserFound")); return true; } diff --git a/vscode/asperheader/src/modules/messageReference.ts b/vscode/asperheader/src/modules/messageReference.ts index 5d77bc9..f94cb8f 100644 --- a/vscode/asperheader/src/modules/messageReference.ts +++ b/vscode/asperheader/src/modules/messageReference.ts @@ -397,6 +397,7 @@ export const messages: Record string> getHeaderDescription: (): string => "Please provide a description: ", getHeaderPurpose: (): string => "Please provide the purpose of the file:", getHeaderTags: (): string => "Please enter the tags for this file, separated by commas:", + graceLines: (): string => "Searching for header closer using grace lines.", headerInjectQuestion: (): string => "No header was found in this document. Would you like to add one?", headerInjectQuestionRefused: (): string => "You decided not to add the a header to the file.", headerNotFound: (): string => "No header was found in this document.", @@ -542,6 +543,7 @@ export const messages: Record string> getHeaderDescription: (): string => "Veuillez fournir une description : ", getHeaderPurpose: (): string => "Veuillez fournir l’objectif du fichier :", getHeaderTags: (): string => "Veuillez saisir les tags de ce fichier, séparés par des virgules :", + graceLines: (): string => "Recherche du marqueur de fin d’en-tête en parcourant des lignes supplémentaires.", headerInjectQuestion: (): string => "Aucun en-tête trouvé dans ce document. Souhaitez-vous en ajouter un ?", headerInjectQuestionRefused: (): string => "Vous avez décidé de ne pas ajouter d'en-tête au fichier.", headerNotFound: (): string => "Aucun en-tête trouvé dans ce document.", @@ -687,6 +689,7 @@ export const messages: Record string> getHeaderDescription: (): string => "Fornisci una descrizione: ", getHeaderPurpose: (): string => "Fornisci lo scopo del file:", getHeaderTags: (): string => "Inserisci i tag per questo file, separati da virgole:", + graceLines: (): string => "Ricerca del marcatore di chiusura dell'intestazione scansionando righe aggiuntive.", headerInjectQuestion: (): string => "Nessuna intestazione trovata in questo documento. Vuoi aggiungerne una?", headerInjectQuestionRefused: (): string => "Hai deciso di non aggiungere un'intestazione al file.", headerNotFound: (): string => "Nessuna intestazione trovata in questo documento.", @@ -832,6 +835,7 @@ export const messages: Record string> getHeaderDescription: (): string => "Por favor, proporciona una descripción: ", getHeaderPurpose: (): string => "Proporcione el propósito del archivo:", getHeaderTags: (): string => "Ingrese las etiquetas para este archivo, separadas por comas:", + graceLines: (): string => "Buscando el marcador de cierre del encabezado escaneando líneas adicionales.", headerInjectQuestion: (): string => "No se encontró encabezado en este documento. ¿Desea agregar uno?", headerInjectQuestionRefused: (): string => "Decidió no agregar un encabezado al archivo.", headerNotFound: (): string => "No se encontró encabezado en este documento.", @@ -977,6 +981,7 @@ export const messages: Record string> getHeaderDescription: () => "Bitte Beschreibung angeben:", getHeaderPurpose: () => "Bitte Zweck der Datei angeben:", getHeaderTags: () => "Bitte Tags für diese Datei eingeben, durch Kommas getrennt:", + graceLines: (): string => "Suche nach dem Header-Schlusszeichen, scanne zusätzliche Zeilen.", headerInjectQuestion: () => "Kein Header gefunden. Möchten Sie einen hinzufügen?", headerInjectQuestionRefused: () => "Sie haben entschieden, keinen Header hinzuzufügen.", headerNotFound: () => "Kein Header in diesem Dokument gefunden.", @@ -1122,6 +1127,7 @@ export const messages: Record string> getHeaderDescription: () => "説明を入力してください: ", getHeaderPurpose: () => "ファイルの目的を入力してください: ", getHeaderTags: () => "このファイルのタグをカンマで区切って入力してください: ", + graceLines: (): string => "ヘッダーの終了マーカーを探索するために追加の行を走査しています。", headerInjectQuestion: () => "このドキュメントにヘッダーが見つかりません。追加しますか?", headerInjectQuestionRefused: () => "ファイルにヘッダーを追加しないことにしました。", headerNotFound: () => "このドキュメントにヘッダーが見つかりません。", @@ -1267,6 +1273,7 @@ export const messages: Record string> getHeaderDescription: () => "설명을 입력하세요: ", getHeaderPurpose: () => "파일의 목적을 입력하세요: ", getHeaderTags: () => "이 파일의 태그를 쉼표로 구분하여 입력하세요: ", + graceLines: (): string => "추가 행을 스캔하여 헤더 종료를 검색합니다.", headerInjectQuestion: () => "이 문서에서 헤더를 찾을 수 없습니다. 추가하시겠습니까?", headerInjectQuestionRefused: () => "파일에 헤더를 추가하지 않기로 결정했습니다.", headerNotFound: () => "이 문서에서 헤더를 찾을 수 없습니다.", @@ -1412,6 +1419,7 @@ export const messages: Record string> getHeaderDescription: () => "Пожалуйста, предоставьте описание: ", getHeaderPurpose: () => "Пожалуйста, укажите назначение файла: ", getHeaderTags: () => "Введите теги для этого файла через запятую: ", + graceLines: (): string => "Поиск конца заголовка, сканирование дополнительных строк.", headerInjectQuestion: () => "Заголовок в этом документе не найден. Хотите добавить его?", headerInjectQuestionRefused: () => "Вы решили не добавлять заголовок в файл.", headerNotFound: () => "Заголовок в этом документе не найден.", @@ -1557,6 +1565,7 @@ export const messages: Record string> getHeaderDescription: () => "Por favor, forneça uma descrição: ", getHeaderPurpose: () => "Por favor, forneça o propósito do arquivo:", getHeaderTags: () => "Digite as tags para este arquivo, separadas por vírgulas:", + graceLines: (): string => "Procurando o marcador de fechamento do cabeçalho examinando linhas adicionais.", headerInjectQuestion: () => "Nenhum cabeçalho encontrado neste documento. Deseja adicionar um?", headerInjectQuestionRefused: () => "Você optou por não adicionar um cabeçalho ao arquivo.", headerNotFound: () => "Nenhum cabeçalho encontrado neste documento.", @@ -1702,6 +1711,7 @@ export const messages: Record string> getHeaderDescription: () => "Lütfen bir açıklama sağlayın: ", getHeaderPurpose: () => "Lütfen dosyanın amacını belirtin:", getHeaderTags: () => "Bu dosya için etiketleri virgülle ayırarak girin:", + graceLines: (): string => "Başlık kapanış işaretini bulmak için ek satırlar taranıyor.", headerInjectQuestion: () => "Bu belgede başlık bulunamadı. Eklemek ister misiniz?", headerInjectQuestionRefused: () => "Dosyaya başlık eklememeyi seçtiniz.", headerNotFound: () => "Bu belgede başlık bulunamadı.", @@ -1847,6 +1857,7 @@ export const messages: Record string> getHeaderDescription: () => "Podaj opis: ", getHeaderPurpose: () => "Podaj cel pliku:", getHeaderTags: () => "Wprowadź tagi dla tego pliku, oddzielone przecinkami:", + graceLines: (): string => "Wyszukiwanie znacznika końca nagłówka, skanuję dodatkowe wiersze.", headerInjectQuestion: () => "Nie znaleziono nagłówka w tym dokumencie. Czy chcesz dodać jeden?", headerInjectQuestionRefused: () => "Zdecydowano nie dodawać nagłówka do pliku.", headerNotFound: () => "Nie znaleziono nagłówka w tym dokumencie.", @@ -1992,6 +2003,7 @@ export const messages: Record string> getHeaderDescription: () => "Zadejte popis: ", getHeaderPurpose: () => "Zadejte účel souboru:", getHeaderTags: () => "Zadejte tagy pro tento soubor, oddělené čárkou:", + graceLines: (): string => "Hledání ukončovací značky hlavičky skenováním dalších řádků.", headerInjectQuestion: () => "V tomto dokumentu nebyla nalezena žádná hlavička. Chcete ji přidat?", headerInjectQuestionRefused: () => "Rozhodli jste se nepřidávat hlavičku do souboru.", headerNotFound: () => "V tomto dokumentu nebyla nalezena žádná hlavička.", @@ -2137,6 +2149,7 @@ export const messages: Record string> getHeaderDescription: () => "Adjon meg egy leírást: ", getHeaderPurpose: () => "Adja meg a fájl célját:", getHeaderTags: () => "Adja meg a fájl címkéit, vesszővel elválasztva:", + graceLines: (): string => "Fejléc lezáró jelének keresése további sorok átvizsgálásával.", headerInjectQuestion: () => "Nem található fejléc ebben a dokumentumban. Szeretne hozzáadni egyet?", headerInjectQuestionRefused: () => "Úgy döntött, hogy nem ad hozzá fejlécet a fájlhoz.", headerNotFound: () => "Nem található fejléc ebben a dokumentumban.", @@ -2282,6 +2295,7 @@ export const messages: Record string> getHeaderDescription: () => "请输入描述:", getHeaderPurpose: () => "请输入文件用途:", getHeaderTags: () => "请输入文件标签,用逗号分隔:", + graceLines: (): string => "使用宽限行搜索头部结束标记。", headerInjectQuestion: () => "未找到头部。是否添加一个?", headerInjectQuestionRefused: () => "您选择不向文件添加头部。", headerNotFound: () => "未找到头部。", @@ -2427,6 +2441,7 @@ export const messages: Record string> getHeaderDescription: () => "請提供描述:", getHeaderPurpose: () => "請提供檔案用途:", getHeaderTags: () => "請輸入檔案標籤,用逗號分隔:", + graceLines: (): string => "使用寬限行搜尋標頭結束標記。", headerInjectQuestion: () => "未找到頭部。是否添加一個?", headerInjectQuestionRefused: () => "您選擇不向檔案添加頭部。", headerNotFound: () => "未找到頭部。", From 9280d9d77b8f6cc1ceb65012fc9d751e10559682 Mon Sep 17 00:00:00 2001 From: Henry LETELLIER Date: Mon, 16 Feb 2026 13:14:48 +0100 Subject: [PATCH 3/3] [UPDATE] the changelog and readme to reflect the changes of the new version --- CHANGELOG.md | 12 ++++++++++-- README.md | 5 +++++ vscode/asperheader/CHANGELOG.md | 12 ++++++++++-- vscode/asperheader/README.md | 5 +++++ 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 124c204..7de303a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/). +## [1.0.19] - 16/02/2026 + +### Fixed + +- processing of the description entry when charage returns are provided. (comments in front of the description content are now properly prepended) +- header checking (issue of a closing line being before the opening line) +- 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) + ## [1.0.18] - 7/02/2026 -## Added +### Added - language prepend option - language append option @@ -18,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - tags to make the extension easier to get discovered on the different marketplaces - 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) -## Fixed +### Fixed - issue introduced in version 1.0.17 where an extra line would be added after each single comment line. diff --git a/README.md b/README.md index db17d4c..fb03ee3 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,11 @@ The extension currently supports the following languages: - Fix issue where version 1.0.17 would add extra lines between single line comments in the header - Add tags to the extension to make it easier to find on the marketplaces +### 1.0.19 + +- Fix processing of the description entry when charage returns are provided. (comments in front of the description content are now properly prepended) +- 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) + --- ## Community diff --git a/vscode/asperheader/CHANGELOG.md b/vscode/asperheader/CHANGELOG.md index 124c204..7de303a 100644 --- a/vscode/asperheader/CHANGELOG.md +++ b/vscode/asperheader/CHANGELOG.md @@ -5,9 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/). +## [1.0.19] - 16/02/2026 + +### Fixed + +- processing of the description entry when charage returns are provided. (comments in front of the description content are now properly prepended) +- header checking (issue of a closing line being before the opening line) +- 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) + ## [1.0.18] - 7/02/2026 -## Added +### Added - language prepend option - language append option @@ -18,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - tags to make the extension easier to get discovered on the different marketplaces - 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) -## Fixed +### Fixed - issue introduced in version 1.0.17 where an extra line would be added after each single comment line. diff --git a/vscode/asperheader/README.md b/vscode/asperheader/README.md index db17d4c..fb03ee3 100644 --- a/vscode/asperheader/README.md +++ b/vscode/asperheader/README.md @@ -260,6 +260,11 @@ The extension currently supports the following languages: - Fix issue where version 1.0.17 would add extra lines between single line comments in the header - Add tags to the extension to make it easier to find on the marketplaces +### 1.0.19 + +- Fix processing of the description entry when charage returns are provided. (comments in front of the description content are now properly prepended) +- 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) + --- ## Community