mirror of
1
0
Fork 0
This commit is contained in:
Tristan B. Kildaire 2020-05-06 18:18:21 +02:00
parent 0e634a0355
commit 9de6a3d0e0
1 changed files with 9 additions and 6 deletions

View File

@ -343,18 +343,21 @@ void newEditor(struct Session* session)
}
else
{
/* Map current xy fileX,fileY to linear address */
unsigned int f = map(session);
unsigned int fFinal = f+session->fileX;
/* `newLineAfterOffset` is the offset to the character after `\n` */
unsigned int newLineAfterOffset = map(session);
/* `finalOffset` is the new line offset with file cursor */
unsigned int finalOffset = newLineAfterOffset+session->fileX;
/**
* If the final linear address is greater-then
* or equal to the current size we must then
* expand the buffer.
*/
if(fFinal >= session->size)
if(finalOffset >= session->size)
{
session->size++;
/* Increase the size by fFInal-session->size */
session->size = finalOffset+session->fileX;
}
else
@ -364,7 +367,7 @@ void newEditor(struct Session* session)
/* Set data at current position */
*(session->data+fFinal) = s;
*(session->data+finalOffset) = s;
/* TODO: As we type position increases */
session->fileX++;