Golded+ can crash in editor if line is 0 char long.

This commit is contained in:
Ianos Gnatiuc 2006-06-05 19:03:19 +00:00
parent 2882ba419c
commit 86c2e2973e

View File

@ -725,14 +725,16 @@ int IEclass::downoneline(uint __row) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void IEclass::GoEOL() { void IEclass::GoEOL()
{
GFTRK("EditGoEOL"); GFTRK("EditGoEOL");
// Move cursor to the last char on the line // Move cursor to the last char on the line
col = currline->txt.length(); if (mincol != (col = currline->txt.length()))
if((currline->txt[col-1] == '\n') or ((col != mincol) and (currline->txt[col-1] == ' '))) {
--col; if ((currline->txt[col-1] == '\n') || (currline->txt[col-1] == ' '))
--col;
}
// String must not be longer than the window width // String must not be longer than the window width
_test_haltab(col > maxcol, col, maxcol); _test_haltab(col > maxcol, col, maxcol);
@ -1276,14 +1278,20 @@ void IEclass::insertchar(char __ch) {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
void IEclass::DelChar() { void IEclass::DelChar()
{
GFTRK("EditDelChar"); GFTRK("EditDelChar");
Line* _thisline = currline; Line* _thisline = currline;
Line* _nextline = currline->next; Line* _nextline = currline->next;
uint _thislen = _thisline->txt.length(); uint _thislen = _thisline->txt.length();
if (!_nextline && (col == _thislen - 1) && (_thisline->txt[col] == '\n'))
{
GFTRK(0);
return;
}
// Cannot delete at or beyond the nul-terminator // Cannot delete at or beyond the nul-terminator
if(col < _thislen) { if(col < _thislen) {
Undo->PushItem(EDIT_UNDO_DEL_CHAR|batch_mode); Undo->PushItem(EDIT_UNDO_DEL_CHAR|batch_mode);