From kde-commits Tue Dec 31 19:36:33 2013 From: Michal Humpula Date: Tue, 31 Dec 2013 19:36:33 +0000 To: kde-commits Subject: [kate] /: vi-mode: fix crash when word lefting in insert mode Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=138851860627692 Git commit adf91f91f5d4a93dfed3029196018818e025c559 by Michal Humpula. Committed on 31/12/2013 at 19:34. Pushed by michalhumpula into branch 'master'. vi-mode: fix crash when word lefting in insert mode M +4 -0 part/vimode/kateviinsertmode.cpp M +1 -0 tests/vimode_test.cpp http://commits.kde.org/kate/adf91f91f5d4a93dfed3029196018818e025c559 diff --git a/part/vimode/kateviinsertmode.cpp b/part/vimode/kateviinsertmod= e.cpp index d7e55b1..e11eda5 100644 --- a/part/vimode/kateviinsertmode.cpp +++ b/part/vimode/kateviinsertmode.cpp @@ -183,6 +183,10 @@ bool KateViInsertMode::commandMoveOneWordLeft() Cursor c( m_view->cursorPosition() ); c =3D findPrevWordStart( c.line(), c.column() ); = + if (!c.isValid()) { + c =3D Cursor(0,0); + } + updateCursor( c ); return true; } diff --git a/tests/vimode_test.cpp b/tests/vimode_test.cpp index 1087222..9bb6e1f 100644 --- a/tests/vimode_test.cpp +++ b/tests/vimode_test.cpp @@ -880,6 +880,7 @@ void ViModeTest::InsertModeTests() { // Testing ctrl-left and ctrl-right. DoTest("foo bar", "i\\ctrl-\\rightX\\esc", "foo Xbar"); DoTest("foo bar", "i\\ctrl-\\right\\ctrl-\\rightX\\esc", "foo barX"); + DoTest("foo", "\\endi\\ctrl-\\left\\ctrl-\\leftX", "Xfoo"); // we crashe= d here before = // Enter/ Return. DoTest("", "ifoo\\enterbar", "foo\nbar");