Commit Graph

69 Commits

Author SHA1 Message Date
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Kurtis Rader
9c7c9cf7d9 [cleanup] trivial golint suggested changes
As with commit #eb2a792 I acknowledge that `golint` recommendations are
controversial and should not automatically be acted on. Nonetheless,
this change fixes legitimate lint issues such as copy/paste cleanups,
style problems I introduced (`i += 1` versus `i++`) or method/var comments
that are not in the preferred form.
2020-12-25 01:11:33 +00:00
Qi Xiao
b11fe9d257 pkg/cli: Treat Ctrl-H the same way as Backspace in CodeArea's default key handler.
This fixes #1178.
2020-11-07 18:44:18 +00:00
Qi Xiao
e919c53c8b Minor fixup for navigation mode. 2020-11-07 18:37:18 +00:00
Kurtis Rader
a943dc764a Improve navigation mode corner cases
There are some Navigation mode corner cases whose current behavior is
surprising. Such as inserting a space before the filename when the space
isn't wanted or redundant. Also, selecting an empty directory and pressing
Enter should insert nothing rather than an empty string.

Fixes #1169
2020-11-07 13:17:00 -05:00
Shengjing Zhu
6c08de0ff3 Fix typos found by codespell 2020-10-10 22:47:50 +01:00
Kurtis Rader
7bbf75756c Replace "kr" package dependency with "creack"
I was working on issue #661 and noticed that github.com/kr/pty was dead
when I ran into a problem with that module on macOS (GOARCH == darwin).
Replace that dependency with github.com/creack/pty which is ostensibly
being actively maintained.

I also chose to remove a couple of obsolete module signatures at the
same time.
2020-10-10 22:41:09 +01:00
Qi Xiao
d27e7ee254 pkg/testutil: Remove InTestDirWithSetup. 2020-09-04 21:42:19 +01:00
Qi Xiao
b271a85279 pkg/eval/evaltest: Move InTempHome to pkg/testutil. 2020-09-03 06:55:14 +01:00
Qi Xiao
bb122024dd pkg/eval: Move test framework into new evaltest package. 2020-09-03 06:51:21 +01:00
Qi Xiao
11898f763a pkg/util: Break into fsutil/ and logutil/. 2020-09-03 05:27:18 +01:00
Qi Xiao
6dd122107c pkg: Move multierror.go from util/ to diag/. 2020-09-03 05:12:55 +01:00
Qi Xiao
48919bcb24 pkg/: Move test utilities from util/ to testutil/. 2020-09-03 04:55:16 +01:00
Qi Xiao
80dcc22bc8 pkg/cli: apptest/ -> clitest/. 2020-09-03 04:44:55 +01:00
Kurtis Rader
b5b3a0d607 go vet cleanup
Most of the code uses keyed fields in composite literals; i.e., struct
literals. However, running `go vet ./...` reports a few places that use
anonymous fields. This modifies those composite literals to use keyed
fields. This does make the code a bit more verbose without reducing
the likelihood of a bug. But it does make the code more consistent, use
best practices, and make it easier to notice if a potential problem is
introduced when running `go vet ./...` since that command now produces
no diagnostic output.

I considered adding a `make vet` target that explicitly ran

    go vet -composites=false ./...

I decided not to do that since consistently using keyed composite literals
is preferable to having a mix of keyed and unkeyed composite literals.

This also removes the unused `ExampleLoop` function which causes this
`go vet` warning:

    pkg/cli/loop_test.go:130:1: ExampleLoop refers to unknown identifier: Loop
2020-09-03 04:24:06 +01:00
Kurtis Rader
eed744044c Eliminate sys.Ioctl
I started by writing tests for sys.Ioctl but after I had 100% coverage
of that function it occurred to me the function could be eliminated.

Related #1062
2020-08-27 15:51:29 +01:00
Qi Xiao
9169f803ea pkg/ui: Add a Concat function for concatenating multiple Text's. 2020-08-25 22:34:19 +01:00
Qi Xiao
8b2e669a5f Remove unused code. 2020-08-23 16:04:44 +01:00
Kurtis Rader
28798ac053 Convert "XXX" to "TODO" comments
I stumbled across a comment that began with "XXX". It was clearly meant as
a "TODO" comment. This changes all such occurrences. However, a few "XXX"
comments are ambiguous and a better prefix might be "WARNING". The "TODO"
prefix at least ensures someone, eventually, looks into the situation
and either rewords the comment or fixes the problem. This change means
everyone can assume searching for "// TODO" will find all such comments
rather than requiring they also know to search for "// XXX".
2020-08-16 16:29:34 +01:00
Qi Xiao
a90e8eb75d Revert "Eliminate sys.Ioctl"
Results in "failed to put myself in foreground" errors.

This reverts commit bea90271b0.
2020-08-16 14:23:37 +01:00
Kurtis Rader
bea90271b0 Eliminate sys.Ioctl
I started by writing tests for sys.Ioctl but after I had 100% coverage
of that function it occurred to me the function could be eliminated.

Related #1062
2020-08-16 14:14:48 +01:00
Qi Xiao
8f410a24be pkg/util: Move environment variable names to a new package.
Also document that this package should be broken up.
2020-08-16 14:12:48 +01:00
Kurtis Rader
e04c503431 Replace "LS_COLORS" literals with a constant 2020-08-16 14:05:13 +01:00
Kurtis Rader
eb2a792301 Fix some lint warnings
In addition to an uncontroversial spelling fix this addresses several,
related, warnings produced by the `golint` tool. In general I agree with
golint that unnecessary "else" blocks should be avoided. So this change
refactors those cases.

Note: I recognize that `golint` is deprecated (see
https://github.com/golang/go/issues/38968) since it is no longer being
maintained and there is controversy about its set of warnings. Nonetheless,
it appears that the warnings it emits for this project are all reasonable
and actionable with one potential exception: the naming of the `map_`
method in pkg/eval/compile_value.go.
2020-08-01 23:07:50 +01:00
Qi Xiao
c2c6254316 pkg/edit: Fix race conditions. 2020-07-14 20:43:11 +01:00
Qi Xiao
3501b945aa Rewrite pkg/cli/histutil.
- Organize code around two interfaces, Store and Cursor.

- Ensure that a session store is always available, even if the DB is not
  accessible.

This fixes #909.
2020-07-13 23:46:43 +01:00
Kurtis Rader
c30a9ff9ad Tell external cmds to ignore job control signals
Since elvish does not support job control it should run all external
commands with the tty job control signals set to be ignored. See "APUE",
third edition, page 379.

This doesn't actually fix the problem in the case of broken programs
like vim which blindly assume the parent process implements job control.
But there isn't much we can do about that other than try to get those
programs to pay attention to being told to ignore SIGTSTP.

Fixes #988
2020-07-11 14:18:42 +01:00
Qi Xiao
fbfce20b67 pkg/cli: Clean up abbreviation code. 2020-06-14 00:32:10 +01:00
Kurtis Rader
d061a258ea
Add $edit:small-word-abbr, and document $edit:{small-word- ''}abbr (#980)
Augment the implementation by adding support for small word based
expansion to that mimics typical editor behavior. This also makes it
safer to create and use abbreviations that consist of alphanum sequences
without having them expanded in unexpected places.

Resolves #947
2020-06-13 23:51:12 +01:00
Qi Xiao
913d7385ed pkg/edit/highlight: Force bright-white FG in error regions.
The current style of red BG makes for low contrast on white-on-black color
palettes. Force its foreground to bright-white to work well in all situations.
2020-05-03 20:22:32 +01:00
Kurtis Rader
4bfb6e2aad Fix how [ctrl-v] works on BSD systems
On BSD systems iexten has to be explicitly disabled. Whereas on Linux
systems it is implicitly ignored if icanon is disabled.

Fixes #917
2020-04-24 21:41:35 +01:00
Qi Xiao
a36a372624 pkg: Fix small issues found by staticcheck. 2020-04-13 13:56:10 +01:00
Qi Xiao
15a5745636 pkg/cli/apptest: Revise the godoc for StartReadCode. 2020-04-12 21:50:47 +01:00
Qi Xiao
3037f6c8bf pkg/util: Move the wcwidth utilities to a new package, and add more tests.
This addresses #944.
2020-04-06 12:00:01 +01:00
Qi Xiao
b8eee7a29f pkg/cli/term: Add bare-bone unit test for writer.go. 2020-04-04 01:25:01 +01:00
Qi Xiao
df6300b1ad pkg/cli/tty_unix_test.go: Ignore SIGURG when testing on the signal channel. 2020-04-03 23:28:50 +01:00
Qi Xiao
770fd8e6c4 Scale all test timeouts with $ELVISH_TEST_TIME_SCALE. 2020-04-03 22:12:20 +01:00
Qi Xiao
50c41a4692 pkg/cli/addons/location: Use util.TildeAbbr instead of its custom version. 2020-04-03 02:09:13 +01:00
Qi Xiao
8db99be082 pkg/cli/lscolors: Remove unused code.
This addresses #944.
2020-04-02 05:45:52 +01:00
Qi Xiao
31f0eaa7b0 [cleanup] pkg: Remove ineffectual assignments. 2020-04-01 00:17:09 +01:00
Qi Xiao
0234616e9f [cleanup] pkg: Fix misspellings in code. 2020-04-01 00:12:11 +01:00
Qi Xiao
647b6446f6 pkg/cli/apptest: Guard access to buffers in fakeTTY with mutexes.
This addresses race conditions found when running "go test -race pkg/edit".

This addresses #73.
2020-03-29 00:18:42 +00:00
Qi Xiao
d4b3b6b7ef pkg/cli/addons/instant: Fix a race condition.
The w.update call was after app.MutateState, so it could potentially race with a
w.Render call (which calls w.update). Moving it before app.MutateState fixes the
race condition.

This addresses #73.
2020-03-29 00:10:39 +00:00
Qi Xiao
d35111c7b0 Format Go files and rerun go generate. 2020-03-28 21:38:17 +00:00
Qi Xiao
52ffb7e1cf pkg/cli: Copy state deeply in ColView.CopyState.
This resolves a data race uncovered by the test of pkg/cli/addons/navigation.

This addresses #73.
2020-03-25 22:23:33 +00:00
Qi Xiao
acb9511584 pkg/cli/apptest: Fix race when accessing eventCh. 2020-01-12 16:20:36 -05:00
Qi Xiao
1aa6e057e5 pkg/cli: Add a missing doc comment. 2020-01-12 15:27:36 -05:00
Shengjing Zhu
35d978622e pkg/cli: In ListBox.Accept, check index and do nothing if it is out of range.
Fixes: #891
2020-01-02 15:12:32 +00:00
Qi Xiao
6c011a8018 pkg/cli: In the CodeArea widget, do not consult key binding when pasting.
This fixes #890.
2020-01-01 23:50:36 +00:00
Qi Xiao
4ba4afe605 pkg/cli: Stricten the test that App does not read more events than needed. 2020-01-01 23:37:17 +00:00