summaryrefslogtreecommitdiffstats
path: root/kate/part/katedocument.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kate/part/katedocument.cpp')
-rw-r--r--kate/part/katedocument.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/kate/part/katedocument.cpp b/kate/part/katedocument.cpp
index 57cecf8a0..7781df55e 100644
--- a/kate/part/katedocument.cpp
+++ b/kate/part/katedocument.cpp
@@ -2411,7 +2411,7 @@ bool KateDocument::openFile(TDEIO::Job * job)
// read dir config (if possible and wanted)
if (!m_reloading)
- readDirConfig ();
+ readDirConfig ();
// do we have success ?
bool success = m_buffer->openFile (m_file);
@@ -3135,15 +3135,27 @@ void KateDocument::backspace( KateView *view, const KateTextCursor& c )
if ((col == 0) && (line == 0))
return;
+ KateTextLine::Ptr tl = m_buffer->plainLine(line);
+ if (!tl)
+ {
+ return;
+ }
+
+ // Make sure to handle surrogate pairs correctly
+ uint fromCol = col - 1;
+ TQChar prevChar = tl->getChar(col - 1);
+ if (prevChar.isLowSurrogate() && tl->getChar(col - 2).isHighSurrogate())
+ {
+ fromCol = col - 2;
+ prevChar = tl->getChar(col - 2);
+ }
+
int complement = 0;
if (col > 0)
{
if (config()->configFlags() & KateDocument::cfAutoBrackets)
{
// if inside empty (), {}, [], '', "" delete both
- KateTextLine::Ptr tl = m_buffer->plainLine(line);
- if(!tl) return;
- TQChar prevChar = tl->getChar(col-1);
TQChar nextChar = tl->getChar(col);
if ( (prevChar == '"' && nextChar == '"') ||
@@ -3158,8 +3170,7 @@ void KateDocument::backspace( KateView *view, const KateTextCursor& c )
if (!(config()->configFlags() & KateDocument::cfBackspaceIndents))
{
// ordinary backspace
- //c.cursor.col--;
- removeText(line, col-1, line, col+complement);
+ removeText(line, fromCol, line, col+complement);
}
else
{
@@ -3215,9 +3226,23 @@ void KateDocument::del( KateView *view, const KateTextCursor& c )
return;
}
- if( c.col() < (int) m_buffer->plainLine(c.line())->length())
+ KateTextLine::Ptr tl = m_buffer->plainLine(c.line());
+ if (!tl)
{
- removeText(c.line(), c.col(), c.line(), c.col()+1);
+ return;
+ }
+ uint lineLen = tl->length();
+ uint col = (uint)c.col();
+ if (col < lineLen)
+ {
+ // Make sure to handle surrogate pairs correctly
+ uint toCol = col + 1;
+ if (tl->getChar(col).isHighSurrogate() && tl->getChar(col + 1).isLowSurrogate())
+ {
+ toCol = col + 2;
+ }
+
+ removeText(c.line(), col, c.line(), toCol);
}
else if ( (uint)c.line() < lastLine() )
{