From c8c22e3ddfa4825f2682e9eebdc003f2d42c28f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Thu, 13 Sep 2018 14:30:11 +0200 Subject: [PATCH] docs --- src/Buffer.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Buffer.ts b/src/Buffer.ts index bc146a15..e7a35d24 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -194,6 +194,18 @@ export class Buffer implements IBuffer { this.scrollBottom = newRows - 1; } + /** + * Translates a string index back to a BufferIndex. + * To get the correct buffer position the string must start at `startCol` 0 + * (default in translateBufferLineToString). + * The method also works on wrapped line strings given rows were not trimmed. + * The method operates on the CharData width attribute, there are no + * additional content or boundary checks. Therefore the string and the buffer + * should not be altered in between. + * @param lineIndex line index the string was retrieved from + * @param stringIndex index within the string + * @param startCol column offset the string was retrieved from + */ public stringIndexToBufferIndex(lineIndex: number, stringIndex: number): BufferIndex { if (!stringIndex) { return [lineIndex, 0];