Commit Graph

6332 Commits

Author SHA1 Message Date
Qi Xiao
5a237d7888 pkg/eval: When compiling, emit autofixes for using unimported builtin modules. 2022-12-11 14:21:09 +00:00
Qi Xiao
7504f7d81a website: Run "go mod tidy". 2022-12-11 12:52:13 +00:00
Qi Xiao
49b7c0c464 pkg/cli: Change highlighter API to return general "tips" rather than errors.
This is to prepare for displaying autofix code snippets in the REPL.
2022-12-11 12:47:48 +00:00
Qi Xiao
584ece1c52 pkg/edit/highlight: Handle multiple compilation errors.
Also document the change in the release notes.
2022-12-09 00:58:21 +00:00
Qi Xiao
78862465a4 pkg/diag: Include line:col of start position in Error and Show methods.
The Error methods used to show the start and end indices, while the Show methods
used to show line ranges.

Showing line:col of the start position seems to be pretty standard; both Go and
Rust do that.

I tried including the line:col of the end position too, but can't find a good
enough format.
2022-12-08 19:07:18 +00:00
Qi Xiao
1acc45cfc2 pkg/edit: Show dedup binding in history listing mode.
Also fix a lot of elvdoc.
2022-12-06 22:51:15 +00:00
Qi Xiao
fe4ca3cb05 website/home.md: Cherrypick fixes from #1628 by @dunsany. 2022-12-06 00:54:38 +00:00
dunsany
6a5c678f7e
Small documentation fixes (#1627)
* Update language.md

* Update str.d.elv
2022-12-03 00:53:32 +00:00
Qi Xiao
7e6bd950b1 pkg/diag: Increase test coverage. 2022-11-30 12:57:02 +00:00
Qi Xiao
121509d8d2 pkg/eval: Preserve all compilation errors.
Multiple compilation errors are packed using diag.PackCognateErrors, like parse errors.
2022-11-30 01:40:03 +00:00
Qi Xiao
94ab1b5390 Generalize parse.Errors and move it to diag.
This generalized type will be used to pack multiple compilation errors.
2022-11-30 01:05:16 +00:00
Qi Xiao
0d861fffce pkg/diag: Capitalize the error type in Error.Show. 2022-11-29 23:32:57 +00:00
Qi Xiao
ad021cc708 pkg/cli: Hide errors in final redraw. 2022-11-29 22:38:14 +00:00
Qi Xiao
3847235a14 pkg/diag: Split Errors into another package.
The Errors function is not related to diag.Error, so keeping it in the same
package is confusing.

Also unexport the MultiError type. This allows its Error method to be
simplified, as it can assume that it always contains at least 2 errors.
2022-11-29 22:13:02 +00:00
Qi Xiao
69715b05fe pkg/eval: Don't use panics for propagating compilation errors.
This also enables saving multiple compilation errors.
2022-11-29 21:17:13 +00:00
Qi Xiao
ff0feb4311 pkg/eval: Refactor index tracking out of argsWalker.
Also redesign the internal API a bit, and rename to argsGetter.
2022-11-29 21:17:07 +00:00
Qi Xiao
6ffd33683c pkg/diag: Document why Ranging is not called Range. 2022-11-29 21:17:07 +00:00
Qi Xiao
b5438db132 pkg/eval: Document which keys are shown in navigation mode's UI. 2022-11-26 17:03:42 +00:00
Qi Xiao
1c4052f83e pkg/edit: Show bindings for toggling filter and hidden files in nav mode.
This fixes #1529.
2022-11-26 16:57:53 +00:00
Qi Xiao
d3eda3dc88 pkg/eval: Remove leftover registration of time commands. 2022-11-26 15:22:18 +00:00
Qi Xiao
cc9238cd42 pkg/parse: Allow $x[].
$x[ ] is already allowed. Neither is useful, but allowed for consistency.

This came up in a comment from @hanche in #1626.
2022-11-26 13:16:47 +00:00
Qi Xiao
ffbd734367 pkg/pprof: Support -allocsprofile. 2022-11-26 12:56:43 +00:00
Qi Xiao
79207b39b6 Fix recording of CPU profiles when using cmd/withprof/elvish.
pprof.Program.Run called pprof.StopCPUProfile in a defer, so the profile will
only capture the extent of that method.

In order to capture an actual Elvish session pprof.StopCPUProfile needs to be
called before the overall program terminates. This is done by allowing the
special "next program" error to carry cleanup functions.

This fixes #1605.
2022-11-26 12:05:39 +00:00
Qi Xiao
4520fc7fd4 pkg/eval: Move time-related builtins to separate file. 2022-11-26 10:41:58 +00:00
Qi Xiao
c64e0ffd4b
.github: Reduce retention of binary artifacts.
Binary artifacts use a lot of storage, so reduce the retention to save some space.
2022-11-23 01:04:09 +00:00
Qi Xiao
352d544638 Bump versions of GitHub actions.
Also specify python-version in setup-python.
2022-11-23 00:42:03 +00:00
Qi Xiao
d44428f4c6 pkg/ui: Add more tests against Text and TextSegment. 2022-11-23 00:40:38 +00:00
Qi Xiao
ab1c1d1a42 website: Run "go mod tidy". 2022-11-22 23:43:33 +00:00
Qi Xiao
dc523d45be website: Preserve $ in the HTML ID of docs for variables.
We are no longer using Pandoc, so this limitation can be lifted.

Also make @cf generate internal links where applicable in non-builtin modules:
"@cf mod:fn" in the doc of "mod" now links to just "#mod:fn" instead of
"mod.html#mod:fn".
2022-11-22 23:42:19 +00:00
Qi Xiao
980cf009ca Parse comment blocks preceding var and fn declarations as doc comments.
Convert all .elv files (including .d.elv files) to use this new format.
2022-11-22 22:59:31 +00:00
Qi Xiao
c0a9294686 .cirrus.yml: Use image family for OpenBSD.
Also actually fix the image family of NetBSD. The old families are no longer
updated after https://github.com/anarazel/pg-vm-images/commit/8e40e1c542346a4f97b637bc2417fe55
ee8772c1
2022-11-21 12:17:43 +00:00
Qi Xiao
bdbe7f3fd1 .cirrus.yml: Use new OpenBSD image.
Also pin the system version of the NetBSD image.
2022-11-21 11:58:11 +00:00
Qi Xiao
f765423119 pkg/mods/file: Split test functions.
Also remove file_unix_test.go now that the tests against /dev/null and /dev/tty
are only run if they can be opened.
2022-11-21 11:44:08 +00:00
Qi Xiao
1f0f2a3e9d pkg/mods/file: Only test is-tty with /dev/tty if it can be opened.
The file cannot be opened when not running in a terminal.
2022-11-21 11:39:33 +00:00
Qi Xiao
eed2f7dabc pkg/mods/file: file:is-tty interprets numbers as port numbers instead of FDs. 2022-11-21 11:30:14 +00:00
Qi Xiao
a3f4384495 Move all elvdocs into .d.elv files.
The elvdocs still use the old format (#elvdoc:fn or #elvdoc:var) for now, but
will be changed to "fn" and "var" forms soon.

Also remove the accidentally committed cmd/mvelvdoc. It has been used to perform
the conversion automatically but is not supposed to be committed.
2022-11-20 21:59:45 +00:00
Qi Xiao
08b7c91402 Fixup for #1616.
- Allow using &key and &less-than together.

- Simplify the implementation with a custom implementation of sort.Interface.
2022-11-20 21:48:23 +00:00
Qi Xiao
973e8e76e2 pkg/eval/vals: Avoid the .Name hack for allowing using $nil for callable.
Also add a test.
2022-11-20 19:31:07 +00:00
Kurtis Rader
306e2d7b8d
Issue 1570 order key option (#1616)
* Allow $nil for Callable options

Related #1570

* Add a `&key` option to the `order` command.

Resolves #1570

Co-authored-by: Qi Xiao <xiaq@users.noreply.github.com>
2022-11-20 19:10:19 +00:00
Qi Xiao
93e28d846b Fixup for #1618.
- Simplify the matcher for compilation errors.

- Various stylistic fixes.
2022-11-20 16:39:01 +00:00
Kurtis Rader
358e52a7f5 Make testing compilation errors more deterministic
A year ago I submitted a change to replace AnyError with tests for specific
errors (see https://github.com/elves/elvish/commit/87656c99).  This does
something similar for DoesNotCompile. This ensures the test does what
is implied and makes correlating specific unit tests with compilation
errors easier.

This includes a couple of changes to compilation error messages to improve
readability (IMHO) but those are not the primary purpose of this change.

Related #1560
2022-11-20 16:33:29 +00:00
Qi Xiao
a18aec1ac8 Fixup for #1598.
- Let file:is-tty always take one argument.

- Revert change to eval.ByteOutput.

- Make sys.IsATTY take a FD instead, to avoid the need to use os.NewFile. Using
  os.NewFile can cause the Go runtime to start polling the file, which
  interferes with Elvish's terminal reader.
2022-11-20 16:21:10 +00:00
Kurtis Rader
23c83323b6 Implement file:is-tty
Resolves #1263
2022-11-20 16:03:34 +00:00
Qi Xiao
6c6797b4c1 Remove use of "e.g.," and "i.e.,".
Some of the uses are replaced by plain English phrases like "such as", and the
remaining have the trailing commas removed.
2022-11-20 15:44:29 +00:00
Kurtis Rader
abf1fc5bd3 Remove support for shared vars
Proactively remove support for shared vars per the discussions in issue
https://b.elv.sh/1222 and the IM channels. This feature is not used
by Elvish itself and is not believed to be used by any Elvish users.
Removing this (presumptively) unused feature makes it simpler to replace
the existing BoltDB store of interactive command/location history with a
simpler flat file implementation (such as used by Bash and Fish). Also,
eliminating shared var support makes it explicit that solving issue #1222
doesn't need to deal with that feature.

Related #1222
2022-11-20 15:25:11 +00:00
Qi Xiao
1a84c6f71e Merge branch 'integrate-pr' 2022-11-20 15:13:29 +00:00
Qi Xiao
3a0b1242ac Fixup for #1591.
- Keep more metrics than just the minimal duration.

- Change default &min-time to 1s.

- Don't allow unitless value as &min-time.

- Rename &on-run to &on-run-end, and &min-iters to &min-runs.
2022-11-20 15:13:25 +00:00
Qi Xiao
27f6ab2aa1 pkg/eval/errs: Fix misleading message in OutOfRange.Error.
The method returns a message saying that there is no valid value if ValidHigh <
ValidLow. This was useful when these fields were numbers, but since they are now
strings this no longer works.
2022-11-20 15:11:57 +00:00
Qi Xiao
0203a2ad82 website/cmd/elvdoc: Fix a bug handling comment blocks from multiple files. 2022-11-19 21:47:31 +00:00
Kurtis Rader
b88b377c0c Documentation typo to a backslash on Windows
While working on other changes I noticed that
https://elv.sh/ref/path.html#path:separator used a double backslash for
the Windows example while it should have used a single backslash.
2022-11-19 00:07:15 +00:00