Commit Graph

3345 Commits

Author SHA1 Message Date
Jöran Karl
c51f848df2 action/command: On reload prevent overwriting settings.json 2024-08-18 21:10:37 +02:00
Jöran Karl
7f6e5bc860 action/command: On reload check and inform about errors 2024-08-18 21:10:37 +02:00
Jöran Karl
9afcb80c95 action/command: Let reload really reload the settings.json 2024-08-18 21:10:37 +02:00
Dmytro Maluka
fd3a00226c
Add matchbraceleft option (#3432)
Add `matchbraceleft` option to allow disabling the default behavior
matching not just the brace under cursor but also the brace to the left
of it (which is arguably convenient, but also ambiguous and
non-intuitive). With `matchbraceleft` disabled, micro will only match
the brace character that is precisely under the cursor, and also when
jumping to the matching brace, will always move cursor precisely to the
matching brace character, not to the character next to it.

Nota bene: historical journey:

- There was already a `matchbraceleft` option introduced in commit
  ea6a87d41a, when this feature (matching brace to the left) was
  introduced first time. That time it was matching _only_ the brace
  to the left, _instead_ of the brace under the cursor, and was
  disabled by default.

- Later this feature was removed during the big refactoring of micro.

- Then this feature was reintroduced again in commit d1e713ce08, in
  its present form (i.e. combined brace matching both under the cursor
  and to the left, simulating I-beam cursor behavior), and it was
  introduced unconditionally, without an option to disable it.

- Since then, multiple users complained about this feature and asked
  for an option to disable it, so now we are reintroducing it as an
  option again (this time enabled by default though).
2024-08-18 21:08:05 +02:00
Jöran Karl
f88ac6d4fe
Merge pull request #3430 from dmaluka/calchash-fixes
Various bugfixes and improvements around buffer md5 hash calculation and `fastdirty`
2024-08-18 19:56:06 +02:00
Dmytro Maluka
0b15b57e63 buffer: Set fastdirty=true for large file when reopening
Similarly to how we force `fastdirty` to true when opening a large file
(when creating the buffer), force it also when reopening a file, in case
the file on disk became large since we opened it.
2024-08-18 15:51:47 +02:00
Dmytro Maluka
d31095fe8f buffer/settings: Add comment why do we need to zero origHash 2024-08-18 15:51:47 +02:00
Dmytro Maluka
7fe98ccfee calcHash: Remove checking file size
Let calcHash() unconditionally hash whatever buffer it is asked to hash,
and let its callers explicitly check if the buffer is too large before
calling calcHash(). This makes things simpler and less error-prone
(no extra source of truth about whether the file is too large, we don't
need to remember to check if calcHash() fails, we can be sure calcHash()
will actually update the provided hash), and actually faster (since just
calculating the buffer size, i.e. adding line lengths, is faster than
md5 calculation).

In particular, this fixes the following bugs:

1. Since ReOpen() doesn't check calcHash() return value, if the reloaded
   file is too large while the old version of the file is not,
   calcHash() returns ErrFileTooLarge and doesn't update origHash, so
   so Modified() returns true since the reloaded file's md5 sum doesn't
   match the old origHash, so micro wrongly reports the newly reloaded
   file as modified.

2. Since Modified() doesn't check calcHash() return value, Modified()
   may return false positives or false negatives if the buffer has
   *just* become too large so calcHash() returns ErrFileTooLarge and
   doesn't update `buff`.
2024-08-18 15:42:18 +02:00
Dmytro Maluka
93efc9eabe buffer/settings: Don't use Modified() before we updated origHash
When we have already enabled `fastdirty` but have not updated origHash
yet, we shouldn't use Modified() since it depends on origHash which is
still outdated, and thus returns wrong values.

This fixes the following issue: enable `fastdirty`, modify the buffer,
save the buffer and disable `fastdirty` -> micro wrongly reports the
buffer as modified (whereas it has just been saved).

Note that this fix, though, also causes a regression: e.g. if we run
`set fastdirty false` while fastdirty is already disabled, micro may
unexpectedly report a non-modified buffer as modified (in the case if
isModified is true but the buffer it actually not modified, since its
md5 sum matches and fastdirty is disabled), since this fix assumes that
since we are disabling fastdirty, it has been enabled. This shall be
fixed by PR #3343 which makes `set` do nothing if the option value
doesn't change.
2024-08-18 15:39:47 +02:00
Jöran Karl
352fd2be22 buffer/settings: On fastdirty off set to on in case of "large file"
This behavior is then aligned to the actual documentation of `fastdirty`.
Additionally set the origHash to zero in case the buffer was already modified.
2024-08-18 14:01:35 +02:00
Dmytro Maluka
c0f6b65ed6 calcHash: use correct line endings
Make calcHash() respect the buffer's file endings (unix vs dos), to make
its calculation of the file size consistent with how we calculate it in
other cases (i.e. when opening or saving the file) and with the
`fastdirty` option documentation, i.e. make calcHash() return
ErrFileTooLarge if and only if the exact file size exceeds 50KB.
2024-08-18 13:35:37 +02:00
Dmytro Maluka
e0f5361d97 calcHash: remove unneeded h.Write() error checks
According to the Go hash package documentation [1]:

type Hash interface {
	// Write (via the embedded io.Writer interface) adds more data to the running hash.
	// It never returns an error.
	io.Writer

[1] https://pkg.go.dev/hash#Hash
2024-08-18 13:35:27 +02:00
Dmytro Maluka
3737979139
Merge pull request #3416 from dmaluka/undo-cursor-fix
Fix cursor moving to an unexpected location after a redo
2024-08-15 16:07:51 +02:00
Neko Box Coder
be69b2580b
Adding missing deselect when calling RemoveAllMultiCursors (#3428)
This adds missing deselect calls that were present previously for
RemoveAllMultiCursors before PR #3352
2024-08-15 16:06:32 +02:00
Jöran Karl
21bb61c5ff
Merge pull request #3418 from JoeKar/fix/nightly-assets
nightly: Fix asset names with `nightly` as version string
2024-08-08 18:37:29 +02:00
Jöran Karl
d744872f4c nightly: Call tools/cross-compile.sh with nightly as argument 2024-08-08 06:20:01 +02:00
Jöran Karl
a9c359a719 tools/cross-compile.sh: Make VERSION configurable 2024-08-08 06:19:59 +02:00
Jöran Karl
1fae584eea tools/cross-compile.sh: Remove unused variables 2024-08-05 23:16:53 +02:00
Dmytro Maluka
0d51035acd undo/redo: Remove no longer needed teCursor temp var 2024-08-04 13:56:03 +02:00
Dmytro Maluka
658c20ff2a undo/redo: Don't change remembered cursor location
Remember the cursor location in TextEvent just once - when the original
text event happens, so that when we redo after an undo, the cursor is
placed at the location where the actual redone modification happens (as
the user would expect), not at the location where the cursor was before
the undo (which may be a completely unrelated location and may be far
away).

Fixes #3411
2024-08-04 13:43:16 +02:00
Justin Su
2259fd10af
Add Shift-Page Up/Down keybindings (#3407)
* Add Shift-Page Up/Down keybindings in defaults_other.go

* Add Shift-Page Up/Down keybindings in defaults_darwin.go

* Document Shift-Page Up/Down keybindings in keybindings.md

* Fix indentation
2024-07-31 20:35:09 +02:00
Justin Su
b8772b69c2
Use // comments for .json (#3388)
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.
2024-07-30 22:58:07 +02:00
Jöran Karl
e042bb3514
release: Use GitHub Actions for manually triggered builds and artifact uploads (#3397) 2024-07-21 13:10:26 +02:00
Dmytro Maluka
d173e527ac
Merge pull request #3352 from dmaluka/action-return-values
Improve return values of some actions + some improvements
2024-07-20 15:52:18 +02:00
hchac
f8e532b0d7
Adding selection for ParagraphPrevious and ParagraphNext. (#3353)
Also tweaked the behavior of Paragraph/{Previous/Next} so that it skips
all empty lines immediately next to cursor position, until it finds the
start/end of the paragraph closest to it. Once it finds the paragraph
closest to it, the same behavior as before applies. With the previous
behavior if the cursor was surrounded by empty lines, then
Paragraph/{Previous/Next} would only jump to the next empty line,
instead of jumping to the start/end of a paragraph.
2024-07-20 12:21:57 +02:00
Dmytro Maluka
0373a63b31 Refactor action execution code
Instead of calling execAction() and then letting it check whether it
should actually execute this action, do this check before calling
execAction(), to make the code clear and straightforward.

Precisely: for multicursor actions, call execAction() in a loop for
every cursor, but for non-multicursor actions, call execAction() just
once, without a loop. This, in particular, allows to get rid of the
hacky "c == nil" check, since we no longer iterate a slice that may
change in the meantime (since SpawnMultiCursor and RemoveMultiCursor
are non-multicursor actions and thus are no longer executed while
iterating the slice).
2024-07-18 23:54:57 +02:00
Dmytro Maluka
765889f610 Fix execution of {Spawn,Remove}MultiCursor in chained actions
- SpawnMultiCursor and RemoveMultiCursor actions change the set of
  cursors, so we cannot assume that it stays the same. So refresh the
  `cursors` list after executing every action in the chain.

- If execAction() did not execute an action since it is not a
  multicursor, it should return true, not false, to not prevent
  executing next actions in the chain.
2024-07-18 23:54:57 +02:00
Dmytro Maluka
5c8bf6b3a6 Improve RemoveAllMultiCursors behavior
Use Deselect() in order to place the cursor at the beginning of the
selection, not at the end of it, and to refresh its LastVisualX.
2024-07-18 23:54:57 +02:00
Dmytro Maluka
aa9c476b1e Improve RemoveMultiCursor behavior
If the original selection was not done by the user manually but as a
result of the initial SpawnMultiCursor, deselect this original selection
if we execute RemoveMultiCursor and there is no multicursor to remove
(i.e. the original spawned cursor is the only one). This improves user
experience by making RemoveMultiCursor behavior nicely symmetrical to
SpawnMultiCursor.
2024-07-18 23:54:57 +02:00
Dmytro Maluka
2793c37a94 Fix SkipMultiCursor behavior when there is no selection
When there is no selection (i.e. selection is empty), SkipMultiCursor
searches for the empty text, "finds" it as the beginning of the buffer,
and as a result, jumps to the beginning of the buffer, which confuses
the user. Fix it.
2024-07-18 23:54:57 +02:00
Dmytro Maluka
7e09a921e4 Make it clear that ClearStatus is the same as ClearInfo
ClearInfo and ClearStatus actions do exactly the same thing. Let's keep
them both, for compatibility reasons (who knows how many users are using
either of the two), but at least document that there is no difference
between the two.
2024-07-18 23:54:56 +02:00
Dmytro Maluka
e2e8baf4f3 Improve misc actions return values 2024-07-18 23:54:14 +02:00
Dmytro Maluka
fc5d83f6c6 Improve RemoveMultiCursor & RemoveAllMultiCursors actions return values 2024-07-18 23:54:14 +02:00
Dmytro Maluka
781f057e6f Improve Undo & Redo actions return values
Return false if there is nothing to undo/redo.

This also fixes false "Undid action" and "Redid actions" infobar
messages in the case when no action was actually undone or redone.
2024-07-18 23:54:14 +02:00
Jöran Karl
762e31f2fd
Merge pull request #3333 from masmu/feature/reset-search
Implemented `ResetSearch` and allow action chaining of `FindNext` and `FindPrevious`
2024-07-16 06:21:47 +02:00
Dmytro Maluka
1f71667616
Fix termpane not closing automatically after terminal job finished (#3386)
Fix regression caused by the fix 0de16334d3 ("micro: Don't forward
nil events into the sub event handler"): even if the terminal was
started with `wait` set to false, it is not closed immediately after
it finished its job, instead it shows "Press enter to close".

The reason is that since the commit b68461cf72 ("Terminal plugin
callback support") the termpane code has been (slightly hackily) relying
on nil events as notifications to close the terminal after it finished
its job. So fix this by introducing a separate CloseTerms() function
for notifying termpanes about that, decoupled from HandleEvent() which
is for tcell events only.
2024-07-15 09:35:50 +02:00
Neko Box Coder
a10624cc33
Fixing tabmove not working properly when there's a split in pane (#3371) 2024-07-07 10:20:22 +02:00
Massimo Mund
bbf6ec292e Implemented 'ResetSearch' to allow a search to be resetted
Added ResetSearch to the list of bindable actions in keybindings.md
2024-07-04 15:44:36 +02:00
Dmytro Maluka
dc7759204b
Merge pull request #3357 from niten94/shell-sigint-recv
Receive SIGINT only in RunInteractiveShell
2024-06-28 10:37:41 +02:00
niten94
a84aa225ab Return error with start in RunInteractiveShell
Print and return error with process start in RunInteractiveShell if
process was not able to be started. Wait until enter is pressed even if
`wait` is false.

Co-authored-by: Dmitry Maluka <dmitrymaluka@gmail.com>
2024-06-22 21:21:13 +08:00
mdom
882b98f3f1
Fix typo in README.md (#3361) 2024-06-21 16:53:25 +02:00
Jöran Karl
0fa4a3a8db
Merge pull request #3354 from JoeKar/feature/action-nightly
workflows: General improvements
2024-06-20 23:24:51 +02:00
Jöran Karl
531c7d88e2 workflow: Fetch with a fetch-depth of 0 and fetch-tags true
This will allow us to read the whole history especially all the tags.
2024-06-20 22:59:05 +02:00
Jöran Karl
c58ed0e51a workflows: Perform the setup uncached 2024-06-20 22:59:05 +02:00
Jöran Karl
f475220e67 workflows/test: Bump version of setup & checkout actions
This will correct the following warning:
"Node.js 16 actions are deprecated."
2024-06-20 22:59:05 +02:00
Jöran Karl
57375e0732 workflows/nightly: Allow manual trigger for better testability 2024-06-20 22:59:05 +02:00
Jöran Karl
d98fafd2f9 tools/build-version.go: Remove the git fetch step
build-version.go shall only provide information and not modify the repository
in which it runs.
2024-06-20 22:59:03 +02:00
Jöran Karl
f5a9744bde tools/build-version.go: Improve error verbosity 2024-06-20 22:30:00 +02:00
Borna Lang
a3e25e3701
docs: Improve plugin documentation (#3240)
* docs: Improve documentation

`commands.md`
  - documented the `reopen` command
  - improved the documentation of the `reload` command

`plugins.md`
  - added direct links to relevant external documentation pages
  - rewrote some sections
  - documented missing functions/callbacks
  - added a note about installing/managing plugins

* Omit number of default plugins

Co-authored-by: Jöran Karl <3951388+JoeKar@users.noreply.github.com>

---------

Co-authored-by: Jöran Karl <3951388+JoeKar@users.noreply.github.com>
2024-06-19 21:35:19 +02:00
Maxim Ostapenko
f0f4afa272
Added a way to install the program in ALT Linux (#3348) 2024-06-19 18:56:05 +02:00