Commit Graph

1386 Commits

Author SHA1 Message Date
Qi Xiao
cfc914e9ba New read-bytes builtin to read a fixed number of bytes. 2023-07-20 11:24:01 +01:00
Qi Xiao
93423d3244 Support (struct)map with 'r' or 'w' fields in redirections.
Now that pipe is a structmap and structmaps are considered indistinguishable to
normal maps, IO redirection should support arbitrary maps too.

Update the relevant section in the language spec and rewrite it a bit.
2023-07-18 17:52:06 +01:00
Qi Xiao
ad691e7812 Fix lscolors test on Windows. 2023-07-18 12:35:15 +01:00
Qi Xiao
6481284f58
Merge pull request #1711 from mikelward/1245
Make Concat return a new globPattern.
2023-07-17 23:54:01 +01:00
Qi Xiao
a743f959a2 Add regression test for #1710. 2023-07-17 23:51:11 +01:00
Qi Xiao
6992c0b693 Make pseudomaps print like [^tag &key=value].
Also make file:pipe output a struct map rather than a pseudomap.
2023-07-17 23:41:43 +01:00
Mikel Ward
8796233de4 Make Concat return a new globPattern.
I don't know if this is fully sufficient, but it seems to fix the specific test
case mentioned.

Fixes #1245
2023-07-16 18:28:32 +01:00
Alexandr Shavykin
2e1a1e1d38
Update stat_unix.go
Fixes multihardlink directory styling on unix
2023-07-16 18:46:17 +03:00
Qi Xiao
96752afa4d Make struct maps indistinguishable from maps to Elvish code.
Struct map is a mechanism to let Go code expose simple structs to Elvish code.
The difference between struct maps and maps is convenience for Go code; they
also have different performance characteristics, but since struct maps are
always quite small, the difference is not meaningful for Elvish's use cases.

As a result, there is no good reason that Elvish code needs to be aware of the
difference between struct maps and normal maps. Making them indistinguishable to
Elvish code simplifies the language.

This commit does the following:

- Change Equal, Hash, Kind and Repr to treat struct maps like maps.

- Change Assoc and Dissoc to "promote" struct maps to maps.

- Remove the custom Repr method of parse.Source.

- Update documentation to reflect this change.
2023-07-14 23:57:38 +01:00
Qi Xiao
900cc52b05 Fix the hash code of maps. 2023-07-14 22:01:32 +01:00
Qi Xiao
5edb915d1a Fix build tag of Unix-only test file. 2023-07-13 22:21:36 +01:00
Qi Xiao
34cc3653f9 pkg/cli/modes: Fix the handling of named pipes in nav previews. 2023-07-13 22:12:12 +01:00
Qi Xiao
9a1948b167 pkg/wcwidth: Clarify which part is taken from another implementation.
Also refactor the isCombining function a bit to not depend directly on
combiningRanges.
2023-07-13 21:46:42 +01:00
Qi Xiao
aa24cd2851 pkg/edit/complete: Use default arg generator for RHS of "set" and "tmp".
This fixes #1704.
2023-05-27 10:53:06 +01:00
Qi Xiao
f0c5767ab6 pkg/eval: Use json.Number in from-json. 2023-05-22 07:35:17 +01:00
Qi Xiao
155ea5acb1 pkg/eval: Bump the sleep time in the test for peach more.
Another failure in the Linux ARM64 runner: https://cirrus-ci.com/task/6301954620522496
2023-05-20 11:55:31 +01:00
Qi Xiao
2fe4512556 pkg/eval/vals: Make Repr sort map keys before printing.
This addresses #1495.
2023-05-20 10:52:52 +01:00
Qi Xiao
7c0c3eb82d pkg/eval/vals: Correct the godoc of Cmp. 2023-05-20 10:20:48 +01:00
Qi Xiao
c71995ba9a pkg/eval: Add tests for "order &total". 2023-05-19 17:27:37 +01:00
Qi Xiao
058f9818ae pkg/eval: Fix the equality test in "has-value".
Previously Go's == was used to test for equality when the container is not a
map, which is more strict when Elvish's normal equality test. For example,
"has-value [[foo]] [foo]" used to output false, rather than the expected true.
2023-05-19 17:25:36 +01:00
Qi Xiao
3f4bbff9c5 pkg/eval: Add option for total order to the order and compare commands.
The same code will be used to sort map keys when printing maps.

This addresses #1495.
2023-05-18 23:21:18 +01:00
Qi Xiao
25e27d6bb6 pkg/eval/vals: Make Cmp(a, b) return CmpEqual if Equal(a, b).
Also match the order of branches in Cmp and Equal.
2023-05-18 10:45:42 +01:00
Qi Xiao
1e249ed7fb pkg/eval.cmp -> pkg/eval/vals.Cmp. 2023-05-18 10:31:31 +01:00
Qi Xiao
19bd75db57 pkg/eval: Make the peach test cases print $best-run on failure. 2023-05-08 23:34:04 +01:00
Qi Xiao
0557e2a3be pkg/eval/evaltests: Make APIs of special matchers functions. 2023-05-08 23:27:53 +01:00
Qi Xiao
cf41f7a01c New "os" module.
This addresses #1659.
2023-05-08 22:40:02 +01:00
Qi Xiao
e8696a5de9 pkg/mods/unix: Clean up some comments and a build tag. 2023-05-08 21:43:07 +01:00
Qi Xiao
75ee4d0179 pkg/eval: Increase the base sleep time in peach's unit test to 2ms.
The previous value of 1ms caused some false positive on Cirrus's Linux ARM64 runner.
2023-05-07 22:38:22 +01:00
Qi Xiao
ae087dc1e4 pkg/eval: Don't use the new context.Cause API.
Elvish should still be buildable with Go 1.19.
2023-05-07 22:37:08 +01:00
Qi Xiao
f54fe608e8 Clean up some code from adding Context to Frame. 2023-05-07 21:49:27 +01:00
Qi Xiao
da576e221c pkg/eval: Use a Context inside Frame to pass interrupts. 2023-05-07 21:44:28 +01:00
Qi Xiao
6ecc2b306c Fixup for #1691. 2023-05-06 23:55:34 +01:00
Qi Xiao
1f0d1c8251
Merge branch 'num-workers' into issue-648-peach-num-worker 2023-05-01 22:25:24 +01:00
rsteube
eff34bff12 Implement str:fields 2023-04-23 00:43:02 +01:00
Qi Xiao
27f34b8044 pkg/lsp: Return doc when hovering on the first character of a symbol. 2023-04-23 00:27:41 +01:00
Qi Xiao
6c5d24ad81 Switch to pkg.nimblebun.works/go-lsp for LSP types. 2023-04-23 00:19:26 +01:00
Qi Xiao
1974b30eb6 pkg/lsp: Store parse results synchronously; add tests for hover. 2023-04-23 00:01:32 +01:00
Qi Xiao
bb13140c5b pkg/lsp: Use pkg/parse/np to find the symbol to look up doc for.
Command docs now only show up at command position.

Also look up variable docs.

Remove the now unused parseutil.LeafNodeAtPos.
2023-04-22 22:35:54 +01:00
Qi Xiao
70d77ce849 Move pkg/edit/complete/node_path.go into new package pkg/parse/np. 2023-04-22 22:25:01 +01:00
Qi Xiao
278cce6ff7 pkg/lsp: Fix display of code blocks in on-hover docs.
As can be seen in the screenshot in
https://github.com/elves/elvish/pull/1684#issuecomment-1493016037, the on-hover
doc shows "```elvish" for the code block that contains the usage of the command,
which shouldn't appear in the rendered Markdown.

This is because the response uses the deprecated MarkedString format, where

> The pair of a language and a value is an equivalent to markdown:
> ```${language}
> ${value}
> ```

When this format is used, the "```elvish" code block is embedded inside another
"```markdown" codeblock, which leads to this weird rendering artifact.

Switching to the new MarkupContent format fixes this issue. However, the
github.com/sourcegraph/go-lsp is outdated and doesn't have this type defined, so
define it ourselves for now. In future we should switch to a more up-to-date Go
package that contains the LSP types.

Also remove the superfluous MarkdownShowMaybe function, and just export
doc.Source. The former did nothing useful other than prepending "# symbol". I
tested the on-hover docs of both Go and JavaScript in VS Code, both start with
the declaration of the symbol, not a heading.
2023-04-22 21:28:21 +01:00
Sidharth Kshatriya
e7a591cc6a lsp: provide doc:show in hover, if available 2023-04-22 20:53:39 +01:00
Kurtis Rader
91c819d5d8 Add a &num-workers option to peach
Resolves #648
2023-04-16 20:34:55 -07:00
Qi Xiao
66a4c590eb Explicitly declare all external commands used in epm.elv. 2023-04-16 11:58:13 +01:00
Kurtis Rader
3dad55a252 Remove some external command dependencies
The `epm` module depends unnecessarily on several external commands;
e.g., `cat` and `test`.  Remove those dependencies. It also has a bug in
its `-first-upper` function due to using the obsolete colon slice index
syntax rather than the double period (`..`) syntax. Replace that
function with the `str:title` builtin.

Related: 1661
2023-04-16 11:54:12 +01:00
Qi Xiao
bda2879228 pkg/glob: When enumerating files, keep going if Lstat fails.
When encountering files that can't be lstat'ed, simply ignore them instead of
terminating the entire globbing process. This is consistent with how directories
that can't be read are already silently ignored.

This fixes #1674.
2023-04-10 23:22:21 +01:00
Qi Xiao
89bf04a802 pkg/eval: Construct ui.Text using the functions from the ui package.
This fixes #1668, because the crashing listbox rendering code uses "len(line) >
0" (where line is a ui.Text) to test whether it is non-empty. This test doesn't
work with the ui.Text constructed using "styled ''", which creates a ui.Text
with one empty segment.

The functions from the ui package are guaranteed to never return such ui.Text
instances, so switching the implementation of the styled builtin to functions
from the ui package fixes this.
2023-03-14 21:47:38 +00:00
Qi Xiao
33cca983f1 pkg/sys/ewindows: Regenerate ztyles_windows.go.
Also remove types_src_windows.go; it contains the same content as
types.go.
2023-03-12 22:06:52 +00:00
Kurtis Rader
34bd94dcd6 Remove obsolete build constraints 2023-03-12 21:58:18 +00:00
Qi Xiao
2a4740a523 pkg/sys/eunix: Simplify build constraints for the termiosFlag definition. 2023-03-11 20:08:56 +00:00
Kurtis Rader
2dc067dcb3 Fix some Go build/lint/test constraints 2023-03-11 19:58:54 +00:00