Restore the original meaning of LastVisualX before commit 6d13710d93
("Implement moving cursor up/down within a wrapped line"): last visual x
location of the cursor in a logical line in the buffer, not in a visual
line on the screen (in other words, taking tabs and wide characters into
account, but not taking softwrap into account). And add a separate
LastWrappedVisualX field, similar to LastVisualX but taking softwrap
into account as well.
This allows tracking last x position at the same time for both cases
when we care about softwrap and when we don't care about it. This can be
useful, for example, for implementing cursor up/down movement actions
that always move by logical lines, not by visual lines, even if softwrap
is enabled (in addition to our default CursorUp and CursorDown actions
that move by visual lines).
Also this fixes a minor bug: in InsertTab(), when `tabstospaces` is
enabled and we insert a tab, the amount of inserted spaces depends on
the visual line wrapping (i.e. on the window width), which is probably
not a good idea.
Since we already have the StoreVisualX() helper, use it all over the
place instead of setting LastVisualX directly.
This will allow us to add more logic to StoreVisualX() add let this
extra logic apply everywhere automatically.
Add comments to `.json` files using `//` instead of the default `#`.
Even though JSON does not support comments, JSON5 and JSONC exist, so `//` is a much more sane default. It also improves the experience of editing micro's own config files.
Fix unwanted highlighting of whitespace in the new line when inserting
a newline after a bracket (when hltrailingws is on). To fix it, change
the order of operations: insert the new empty line after all other
things, to avoid moving the cursor between lines after that.
When commenting a block of multiple lines, the comment symbol is added
right before the first non-whitespace character in each line, e.g.:
void somefunc(int a)
{
// if (a) {
// a += 2;
// printf("a = %d\n", a);
// } else {
// printf("none");
// }
}
which isn't quite nice.
Change it to add the comment at the same position on each line, which is
the position of the leftmost non-whitespace in the entire block, e.g.:
void somefunc(int a)
{
// if (a) {
// a += 2;
// printf("a = %d\n", a);
// } else {
// printf("none");
// }
}
Ref #2282
* shellcheck as a new shell linter + runtime.go out of git control
* keep runtime.go and keep both shfmt and shellcheck since we can remove from custom conf
When commenting a selection, the plugin won't just toggle each
line individually but will only uncomment the block if it is all
comments.
The comment plugin also now takes into account any number of spaces
between the comment character and the text. For example '//comment' will
be uncommented properly, as well as '// comment'.
Fixes#1758