Commit Graph

10377 Commits

Author SHA1 Message Date
ridiculousfish
eff4873eca Stop creating subclasses of block_t
Move all block_t creation methods to static methods, and stop creating
subclasses (all of which are now empty).
2019-05-19 14:40:35 -07:00
ridiculousfish
cf92b7626c Migrate event_block's event into block_t 2019-05-19 13:07:06 -07:00
ridiculousfish
8697fa063b Migrate source_block's source_file into block_t
Continue to work towards flattening this hierarchy.
2019-05-19 13:01:59 -07:00
ridiculousfish
fec0e40b5e Migrate function_block name and args into block_t
The goal is to eliminate this block hierarchy.
2019-05-19 12:56:07 -07:00
ridiculousfish
cd7e8f4103 Migrate loop status from blocks into libdata
Blocks will soon need to be shared across parsers. Migrate the loop status
(like break or continue) from the block into the libdata. It turns out we
only ever need one, we don't need to track this per-block.

Make it an enum class.
2019-05-19 12:50:05 -07:00
Fabian Homborg
ff3fe961f4 Add pipeline.expect to flakey tests
This one fails on Travis sometimes, but I've not been able to
reproduce on a real machine.
2019-05-19 20:59:03 +02:00
Fabian Homborg
257c72d8be Document string split superpowers more
[ci skip]
2019-05-19 19:40:48 +02:00
Fabian Homborg
3efa2ad93b Replace wcslen with math 2019-05-19 18:23:33 +02:00
Fabian Homborg
1e9d41f2c1 Remove now-useless code for detecting {}
This can't happen anymore.
2019-05-19 18:23:33 +02:00
Fabian Homborg
967c1d51ee Only do brace expansion if they contain a variable or ","
Brace expansion with single words in it is quite useless - `HEAD@{0}`
expanding to `HEAD@0` breaks git.

So we complicate the rule slightly - if there is no variable expansion
or "," inside of braces, they are just treated as literal braces.

Note that this is technically backwards-incompatible, because

    echo foo{0}

will now print `foo{0}` instead of `foo0`. However that's a
technicality because the braces were literally useless in that case.

Our tests needed to be adjusted, but that's because they are meant to
exercise this in weird ways.

I don't believe this will break any code in practice.

Fixes #5869.
2019-05-19 18:23:27 +02:00
Fabian Homborg
15a5c0ed5f src/screen: Stop falling back to wchar_t
wcstring is perfectly capable of doing this.
2019-05-19 17:32:09 +02:00
Dawid Dziurla
0b3bb0e7c1 Underline every valid entered path (#5872)
* src/highlight: Underline every valid entered path

* update CHANGELOG

* fix highlight test
2019-05-19 10:03:56 +02:00
ridiculousfish
c42eb0eb4f Remove the process from function_block_t
Prior to this fix, a function_block stored a process_t, which was only used
when printing backtraces. Switch this to an array of arguments, and make
various other cleanups around null terminated argument arrays.
2019-05-18 21:09:04 -07:00
ridiculousfish
508c3a8005 Make is_event and other globals part of parser_t libdata 2019-05-18 19:03:45 -07:00
ridiculousfish
c44dae2d73 Migrate certain runtime flags to atomics hidden behind functions 2019-05-18 18:50:28 -07:00
ridiculousfish
4fcb9d1fed Hide no_exec behind a function 2019-05-18 18:50:28 -07:00
ridiculousfish
be41407610 Make have_proc_stat an ordinary function
Removes a mutable global variable.
2019-05-18 18:50:28 -07:00
ridiculousfish
5158ee812b Eliminate the job from block_t
This exists only to support the '--on-job-exit caller' feature.
Just store the calling job ID directly in the parser's libdata.
2019-05-18 18:50:28 -07:00
Fabian Homborg
6e0cf5db6f docs/status: Fix synopsis
[ci skip]
2019-05-14 19:26:52 +02:00
Fabian Homborg
0aead5caf8 Repaint-mode to reexecute the rest if mode-prompt output is empty
We previously checked if fish_mode_prompt existed as a function, but
that's a bad change for those who already set it to an empty function
to have a mode display elsewhere.
2019-05-14 19:26:52 +02:00
ridiculousfish
005e6f2ab8 Revert "Don't service ioport completions if data is available on stdin"
This reverts commit 0453023f7b.

This broke the history tests. Reverting this while I sort it out.
2019-05-14 09:52:49 -07:00
Fabian Homborg
a7b1c2f76a Drop wcwidth ASCII check
Updated widechar_width takes care of it.

Technically, this does ~3 comparisons more per-character (because it
checks variation selectors and such), but that shouldn't really matter.
2019-05-14 09:49:51 +02:00
Fabian Homborg
2d37bc9bd1 Update widechar_width
This includes the change to check ASCII chars first, so we can now
drop our workaround.
2019-05-14 09:49:51 +02:00
Fabian Homborg
752b5362ee Only widen string if necessary
This tried a bunch of times, but only the final one is important.
2019-05-14 09:49:51 +02:00
Fabian Homborg
87b93cd4ca src/history: Only widen bash history lines once
This did str2wcs when checking, then again when adding.
2019-05-14 09:49:51 +02:00
Fabian Homborg
2aaf7fda27 src/history: Stop renarrowing a string in a for-loop
Classic case of doing stuff in a loop that doesn't change. No idea if
the compiler caught it, but I sleep easier now.
2019-05-14 09:49:50 +02:00
David Adam
b0f320481c document kill-path-component stopping at @ or :
Changes from 009ecfd7e6 / #5841.

[ci skip]
2019-05-14 13:18:22 +08:00
ridiculousfish
0453023f7b Don't service ioport completions if data is available on stdin
This defers certain autosuggestions and syntax highlighting until after
large pastes are complete.
2019-05-13 14:16:43 -07:00
ridiculousfish
277db64804 Force termsize back to valid in get_current_winsize()
get_current_winsize() is intended to be lazy. It does the following:

1. Gets the termsize from the kernel
2. Compares it against the current value
3. If changed, sets COLUMNS and LINES variables

Upon setting these variables, we notice that the termsize has changed
and invalidate the termsize. Thus we were doing this work multiple times
on every screen repaint.

Put back an old hack that just marked the termsize as valid at the end
of get_current_winsize().
2019-05-13 14:05:42 -07:00
Fabian Homborg
e22422c073 Don't do fish_setlocale that early
This just sets some special characters that we use in the reader, so
it only needs to be done before the reader is set up.

Which, as it stands, is in env_init().
2019-05-13 16:09:37 +02:00
ridiculousfish
234c97e6d2 Remove some unused variables 2019-05-12 18:23:00 -07:00
ridiculousfish
1719d6f136 Make $status and $pipestatus per-parser
Another step towards allowing multiple parsers to execute in parallel.
2019-05-12 14:00:44 -07:00
ridiculousfish
8031fa3bdb Stop using atomic types for non-primitives
atomic<winsize> requires linking libatomic on some platforms which is
annoying. Remove the one use.

Fixes #5865
2019-05-12 13:07:37 -07:00
ridiculousfish
3d25ce1fd4 Merge remote-tracking branch 'takoyaki/ant_completion' into master 2019-05-11 23:22:45 -07:00
ridiculousfish
1e4ebfa470 Make electric variables a real thing
Use an actual struct to describe electric variables and what is special
about each one.
2019-05-11 19:17:33 -07:00
ridiculousfish
16fd780484 Reimplement the whole variable stack
The variable stack is a mess - confused locking, surprising callouts, and
unclear division of labor. Just reimplement the whole thing.
2019-05-11 19:17:16 -07:00
ridiculousfish
cfddd881ef Make PWD a per-processor variable
Handle this variable specially.
2019-05-11 17:13:34 -07:00
ridiculousfish
ee250aba82 Factor some environment setting into set_scoped_internal
Breaks up a monolith function.
2019-05-11 17:13:34 -07:00
ridiculousfish
15a52d0f0d Centralize some of the logic for walking the environment stack
Prepare to introduce a new node for per-process variables.
2019-05-11 17:13:34 -07:00
Fabian Homborg
adcc70d0b3 wcwidth: Return early for simple ASCII
Characters from space to before DEL are width 1, and they
appear *often*.

So it's quite a good idea to return early for them.

Fixes #5866.
2019-05-11 21:40:35 +02:00
Fabian Homborg
c27c8801af completions/git: Put local branches before unique remotes
With a few remotes, unique remote branches can get quite large, and
you probably mostly work on your own.

[ci skip]
2019-05-11 12:43:05 +02:00
Fabian Homborg
816df47c10 fish_clipboard_paste: Only trim leading whitespace on first line
We remove leading spaces so a paste isn't histignored, but we did so
on all lines, which removed indentation.

[ci skip]
2019-05-11 11:19:21 +02:00
Fabian Homborg
4462f6d600 src/screen: Skip a wcswidth
This stops trying to see if the previous line is wider if it is a
prefix of the current one.

Which turns out to be true often enough that it's a net benefit.
2019-05-11 10:43:38 +02:00
Fabian Homborg
ac983f6c4b src/screen: Stop recomputing wcwidth
This passes character width as an argument for a few functions.

In particular, it hardcodes a width of "1" for a space literal.
There's no reason to compute wcwidth for the length of the prompt.
2019-05-11 10:43:38 +02:00
Fabian Homborg
567b6ed2b5 src/screen: Stop doing a bunch of unnecessary work
This measured *all* the characters on the commandline, and saved all
of them in another wcstring_list_t, just to then do... nothing with
that info.

Also, it did wcslen for something that we already have as wcstring,
reserved a vector and did a bunch of work for autosuggestions that
isn't necessary if we have more than one line.

Instead, we do what we need, which is to figure out if we are
multiline and how wide the first line is.

Fixes #5866.
2019-05-10 17:43:46 +02:00
Fabian Homborg
d2b02a8a61 src/screen: Only check for combining marks if necessary
line_shared_prefix explains in its comment that

> If the prefix ends on a combining character, do not include the
  previous character in the prefix.

But that's not what it does.

Instead, what it appears to do is to return idx for *every* combining
mark. This seems wrong to begin with, and it also requires checking
wcwidth for *every* character.

So instead we don't do that. If we find the mismatch, we check if it's
a combining mark, and then go back to the previous character (i.e. the
one before the one that the combining mark is for).

My tests found no issues with this, other than a 20% reduction in
pasting time.
2019-05-10 17:43:46 +02:00
Fabian Homborg
eb41965ac3 reader: Remove superfluous while-loop
It's possible this was useful at some point, but now it just always
inserts the string the first time.
2019-05-10 17:43:46 +02:00
Fabian Homborg
3262c5ff44 docs: Document that complete -k does last calls first
Fixes #5868.

[ci skip]
2019-05-10 15:39:17 +02:00
Fabian Homborg
50ed5126f1 completions/git: Reorder some completions with --keep-order
They are displayed in LIFO-order, so it makes sense to e.g. put the
recent commits close to last (only before files) for `checkout`.

Fixes #5868.
2019-05-10 15:36:41 +02:00
Mahmoud Al-Qudsi
097d6c3c5b Fix order of operations in tilde comparison
The previous form of the statement evaluated to a constant comparison
and couldn't have been what was actually intended.
2019-05-09 01:22:23 -05:00