#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
Set cursor column after some commands and position the cursor on same
column after vertical movement. If line is too short set cursor to the
end of line but don't remember the new cursor column.
Change-Id: I4f5592925b9b360e7393f6ac966025f1466f483d
Reviewed-by: hjk <qthjk@ovi.com>
Escape inserted string for repeatition, e.g. command "2i<up>" will
insert text "<up><up>".
Undo position for "I" is start of selection or line.
Change-Id: Ic7e6d8dbf712197b36be20b17ef6d1c0814b1a51
Reviewed-by: hjk <qthjk@ovi.com>
Restore selection and cursor position (may have been changed externally)
before any text processing.
Change-Id: I424523512f8f83c276e7d29760aad29bf7921dab
Reviewed-by: hjk <qthjk@ovi.com>
Command 'gv' restores proper position in selection -- except in visual
line mode ('V') only positions at beginning and end are supported.
Change-Id: I0810808606c340b5c18fe7551a2d5fda29abfeca
Reviewed-by: hjk <qthjk@ovi.com>
Commands in visual block mode '[count]A', '[count]I' and 's' (ignores
[count]) are repeated on every selected line (before or after the block
selection).
Task-number: QTCREATORBUG-8366
Change-Id: I9832656248a8706d1bd4066bd8cf49beded1d8aa
Reviewed-by: hjk <qthjk@ovi.com>
Commands '[z' and ']z' to move [count] times to top or bottom of current
folds.
Change-Id: Ia087e47bd5f9d63a2b9a4b2ffd3fc57559dfba6b
Reviewed-by: hjk <qthjk@ovi.com>
It's possible to do '2dzj' to delete everything up to beginning of
second unfolded block or whole folded block.
Change-Id: I080c9ec4d12471faf09cabea3c96b448b5fc7f4d
Reviewed-by: hjk <qthjk@ovi.com>
Restore position on undo and redo after <C-A> and <C-X> commands.
Do not set dot command if no number was found.
Change-Id: Ia4e6d53ecfbd7f56e874d6a39c0939557f6cdc3d
Reviewed-by: hjk <qthjk@ovi.com>
Hexadecimal (prefix '0x' or '0X') and octal (prefix '0') numbers are
unsigned. Decimal number can be signed (with leading '-').
Preserve width of hexadecimal and octal numbers (i.e. append leading
zeroes if result is shorter or remove leading zeroes if any and result
is longer).
Change-Id: I93769546ff40a586458986909fcee1e4e9143bc2
Reviewed-by: hjk <qthjk@ovi.com>
Text inserted without FakeVim's intervention (code completion) is
handled in insert and replace mode so that '.' command also inserts any
externally inserted text.
After movement in insert mode last command (initiated by '.') is not
cleared until new text is inserted.
Deletion in insert mode is part of dot command.
Change-Id: Ic55b3cdecaf4323e88cd321b218fae661de7a63e
Reviewed-by: hjk <qthjk@ovi.com>
Yank followed by vertical movement ends in same column as at the
beginning of the command (or at the end of line if line ha less
columns).
Change-Id: I573a8435ba9b76430fa3778e536726882f4c6ce1
Reviewed-by: hjk <qthjk@ovi.com>
Overwriting a mark with new position and undoing restores the previous
state of the mark.
Creating new mark (not overwriting old value) on a position and undoing
won't remove the mark.
Change-Id: I673874ef9df0aae16f86efe8599a43a77aae19ee
Reviewed-by: hjk <qthjk@ovi.com>
After Ctrl+O combination in insert or replace mode enter command mode
and after a single command (can consist of entering Ex command or can be
switch to other buffer) or escape key return to previous insert or
replace mode. One exception is that if entering insert mode is part of
the command after <C-O> pressing escape key will exit to command mode
(Vim behavior).
Change-Id: I37d684b691157001e2cab156687d6771afdec7b9
Reviewed-by: hjk <qthjk@ovi.com>
Correctly convert Vim regular expression with braces to QRegExp.
E.g. [a-z] in case insensitive mode should be [a-zA-Z].
Change-Id: Iea4e0220ef7d82041884f61b3ee0fed9f912e7b0
Reviewed-by: hjk <qthjk@ovi.com>
Use showcmd Vim option to show current partial command.
Removed unneeded updateMiniBuffer() calls.
Change-Id: Iddacd364b7c92882b6169a6894c89cdb202a32bf
Reviewed-by: hjk <qthjk@ovi.com>
Match same text on same regex in forward and backward search modes.
E.g. with '\w\{2}' Vim regex and 'abc' text always match '<ab>c'
(should never match 'a<bc>' as with QTextDocument::find()).
Change-Id: Ie920c76540f3be426fc7b842d38137e95c1a65b2
Reviewed-by: hjk <qthjk@ovi.com>
Code from handleCommandMode*() was moved to separate handle*SubMode()
methods. The common code is in handleCommandMode() which is called on
user input in command mode. This method additionally handles clearing
flags for command submodes.
Method handleMovement() handles movement input. This method is called if
no command is active (from handleNoSubMode()) or if current incomplete
command can be followed by movement (finishMovement() is called to
finalize the command).
Unneeded finishMovement() calls were removed.
Change-Id: Ib5ca5b6ec252224eee3285680572fb9fcefd0d46
Reviewed-by: hjk <qthjk@ovi.com>
Stop processing dot command or user mapping after it's no longer valid.
For example do not process the "text" part of command "ci)text" if
cursor is not in parenthesis block or "ctXtext" if character 'X' was not
found on current line after cursor. In these cases insert mode is not
set.
Change-Id: I54588f3beeb803e42a566f6381352aff7bb602c7
Reviewed-by: hjk <qthjk@ovi.com>
Commands ciw and diw should work on a single character.
Commands ci), di" and similar should work on in an empty block.
Change-Id: Id166a3fb80fc5ba2672231638ce126bd88b4f3ff
Reviewed-by: hjk <qthjk@ovi.com>
Workaround for crash when setting text cursor position while in edit
block (after QTextCursor::beginEditBlock() call and before
QTextCursor::endEditBlock() call).
Task-number: QTCREATORBUG-8148
Change-Id: I7faab2e878efea4106e375b32526ecd5984feac2
Reviewed-by: hjk <qthjk@ovi.com>
Workaround for crash when in edit block and adding text to the last
empty line.
Change-Id: I46b84074bd6f6fbcae698671716e151ebab98f5b
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: hjk <qthjk@ovi.com>
Added change and join Ex commands.
Ex command range and address with /.../, ?...?, \/, \? and \&.
Change-Id: I23f16d3e454f28bcfcf87aeab500830136546345
Reviewed-by: hjk <qthjk@ovi.com>