From 47a2d62b66ef0ccfa348bdc9029233a39340bfc3 Mon Sep 17 00:00:00 2001 From: LinuxMage Date: Sat, 21 Nov 2015 02:25:10 -0800 Subject: [PATCH] Solves problems with next word. Next-word (w) will now reach the next word when it involves moving the cursor down a line and that line starts with whitespace. It will now also skip over lines that only contain whitespace (like vim). --- src/vibreoffice.vbs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/vibreoffice.vbs b/src/vibreoffice.vbs index 1fe01c3..4dd6247 100644 --- a/src/vibreoffice.vbs +++ b/src/vibreoffice.vbs @@ -975,7 +975,23 @@ Function ProcessMovementKey(keyChar, Optional bExpand, Optional keyModifiers) ElseIf keyChar = "G" Then oTextCursor.gotoEnd(bExpand) ElseIf keyChar = "w" or keyChar = "W" Then + ' Using soley gotoNextWord would mean that the cursor would not be + ' moved to the next word when it involved moving down a line and + ' that line happened to begin with whitespace. It would also mean that + ' the cursor would not skip over lines that only contain whitespace. + oTextCursor.gotoNextWord(bExpand) + getCursor().gotoRange(oTextCursor.getStart(), False) + ' Stop looping when the cursor reaches the start of a word, an empty + ' line, or cannot be moved further (reaches end of file). + Do Until oTextCursor.isStartOfWord() Or (getCursor().isAtStartOfLine() And getCursor().isAtEndOfLine()) + ' gotoNextWord returns false when it cannot further advance the + ' cursor. + If NOT oTextCursor.gotoNextWord(bExpand) Then + Exit Do + End If + getCursor().gotoRange(oTextCursor.getStart(), False) + Loop ElseIf keyChar = "b" or keyChar = "B" Then ' The function gotoPreviousWord causes a lot of problems. The ' following method doesn't have to account for as many special cases. @@ -996,7 +1012,6 @@ Function ProcessMovementKey(keyChar, Optional bExpand, Optional keyModifiers) End If getCursor().goLeft(1, bExpand) Loop - ElseIf keyChar = "e" Then If oTextCursor.isEndOfWord(bExpand) Then oTextCursor.gotoNextWord(bExpand)