1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
Commit graph

87 commits

Author SHA1 Message Date
Ary Borenszweig
96617ad1d5 IRB colorize: take into account recursive arrays and hashes ()
[Bug ]
2019-10-14 21:25:05 -07:00
Nobuyoshi Nakada
ea68bb914a Changed numbered parameter prefix 2019-09-24 21:57:54 +09:00
aycabta
1b02f6c020 Set IRB::Context#return_format on test clarify 2019-08-16 07:10:45 +09:00
Steven Willis
9d2fed2ccd Don't echo results of assignment expressions 2019-08-16 06:02:45 +09:00
Hiroshi SHIBATA
b39efb163d
Aliases capture_output to capture_io for test-unit compatiblity. 2019-08-08 17:19:23 +09:00
aycabta
43b52ac0a5 Revert "Don't echo results of assignment expressions"
This reverts commit 1ee88c51b3.
2019-08-06 20:28:48 +09:00
Steven Willis
1ee88c51b3 Don't echo results of assignment expressions 2019-08-06 20:15:07 +09:00
Takashi Kokubun
2a26c1ea24
Clarify the Ruby version support status in IRB more 2019-06-13 00:41:00 +09:00
Takashi Kokubun
1808029061
make sync-default-gems GEM=irb
Upgrade IRB to 41ea43a4a7

Mostly backport changes.
2019-06-13 00:32:20 +09:00
Nobuyoshi Nakada
88411d350e
Another incomplete string case 2019-06-12 15:30:07 +09:00
Nobuyoshi Nakada
9593e76ac2
Ripper::Lexer: fallback parse error token to the previous one 2019-06-12 15:25:06 +09:00
Takashi Kokubun
0da9205f15
Remove conflict resolution mistake [ci skip]
in de541fe196 🙇
2019-06-04 00:32:17 +09:00
Takashi Kokubun
d21a694075
Improve test_color to prevent regression
Actually de541fe196 was still needed.
This commit would improve the test coverage using the branch.
2019-06-04 00:29:54 +09:00
Takashi Kokubun
de541fe196
colorize_code must return escaped text
This was needed before 0c459af7c2 but it
could be actually useless now. But I added this anyway just in case.
2019-06-04 00:26:02 +09:00
Nobuyoshi Nakada
0c459af7c2
Colorize error characters
* lib/irb/color.rb (IRB::Color.scan): ignore "incomplete end of
  input" error only, to colorize invalid characters, e.g., control
  characters, and invalid symbols, as errors.
2019-06-04 00:14:55 +09:00
Takashi Kokubun
cb40a21da0
Warn compile_error only when input is finished
Let's say we are in progress to write `"foo"`:

```
irb> "fo
```

at this moment, nothing is wrong.
It would be just a normal way to write `"foo"`.

Prior to this commit, the `fo` part was warned because of
5b64d7ac6e. But I think warning such a
normal input is not valuable for users.

However, we'd like to warn `:@1` or `@@1` which is also a syntax error.
Then this commit switches the syntax highlight based on whether the
input text is finished or not. When it's not finished yet, it does not
warn compile_error.
2019-05-31 06:54:00 +09:00
Nobuyoshi Nakada
5b64d7ac6e
Colorize errors more
* lib/irb/color.rb (IRB::Color.colorize_code): colorize
  `compile_error` part as same as `on_parse_error`.
2019-05-29 22:09:54 +09:00
Nobuyoshi Nakada
068d327595
Colorize compile_error as same as on_parse_error 2019-05-29 13:34:19 +09:00
Nobuyoshi Nakada
8a2a5822ca
Colorize error part 2019-05-27 23:08:51 +09:00
Nobuyoshi Nakada
0aa9b003de
context.rb: hide wrapping lines
* lib/irb/context.rb (IRB::Context#evaluate): separate the code
  from wrapping lines to propagate the given exception, not to show
  the wrapping lines when SyntaxError.
2019-05-27 11:05:51 +09:00
Takashi Kokubun
64ee8900c8
Highlight global variable on IRB 2019-05-26 11:32:23 -07:00
Takashi Kokubun
897901283c
Refactor IRB color dispatch
The reason why we were checking lexer state in addition to token was
that we do not want to colorize local variable, method call, etc., while
they share the :on_ident token with a name of method definition which
should be colored as blue.

It means that we're concerned about the lexer state only for :on_ident.
Thus we can skip checking lexer state for non-:on_ident tokens. This
refactoring is based on that idea.

Also, now we manage Ripper's lexer state as Integer (use `|` if you
need to check multiple states). It should be faster than using Array of
Integer because #any? block call is not needed.
2019-05-26 11:03:57 -07:00
aycabta
1226791368 Support :@@cvar and : on colorize 2019-05-27 02:56:05 +09:00
Takashi Kokubun
e50aa359de
Make the imaginary color on IRB close to pry
and sorted the token names alphabetically.
2019-05-26 10:23:04 -07:00
Nobuyoshi Nakada
4f2a7b8001
Colorize imaginary and rational literals 2019-05-26 23:46:14 +09:00
Nobuyoshi Nakada
2ce6365f9c
parse.y: adjust error indicator
* parse.y (parser_yylex): adjust the error indicator of unexpected
  fraction part.

before:
~~~
1.2.3
^~~
~~~

after:
~~~
1.2.3
   ^~
~~~
2019-05-26 18:47:52 +09:00
Nobuyoshi Nakada
02b39daef8
Fix scanner event at invalid syntax
* parse.y (parser_yyerror, parser_compile_error): revert
  r67224 (e5d10cda07) "Flush erred
  token".
2019-05-26 16:24:33 +09:00
Takashi Kokubun
aaf6c678d2
Handle keyword symbol in IRB::Color::SymbolState 2019-05-25 22:32:28 -07:00
Takashi Kokubun
52b09fcee1
Deal with more syntax highlight edge cases
Please refer to the tests again.
2019-05-25 22:29:16 -07:00
Takashi Kokubun
8aba3b7a04
Fix more unintended syntax highlights
See tests for what kind of things are fixed.
2019-05-25 22:07:32 -07:00
Takashi Kokubun
13f58eccda
Always color Symbol as Yellow on IRB::Color
Symbol color was made blue as a workaround because it was hard to
distinguish `foo`s in `:foo` and `def foo; end` (both are :on_ident).
But I wanted to make it yellow like pry.

`:Struct` had the same problem in :on_const. Because the :on_const was
also blue (but underlined and bold), it was not a big issue.

While they're not so problematic since we got a workaround, we also had
a more serious issue for highlighting a symbol like `:"a#{b}c"`.
The first half was considered as Symbol and the last half was considered
as String, because the colorizer did not have a state like a parser.

To approach the last issue, I introduced `IRB::Color::SymbolState` which
is a thin state manager knowing only "the token is Symbol or not". Having
this module magically solves the first two problems as well. So now we
can highlight Symbol as yellow in the perfect manner.
2019-05-25 20:47:33 -07:00
Takashi Kokubun
208ed56e57
Colorize empty embexpr more on IRB::Color 2019-05-25 14:15:08 -07:00
Takashi Kokubun
98be203704
Support some unhandled syntax highlight
Heredoc, %i, :Foo, { 'a': ... }, ...

:'a' is still half-broken.
2019-05-25 08:19:15 -07:00
Takashi Kokubun
ada64aa9e7
Clear IRB::Color escape sequence before newline
because otherwise prompt and other things could be polluted.
2019-05-25 07:49:15 -07:00
Takashi Kokubun
e2db9f4cc3
Add and use Reline::Unicode.escape_for_print 2019-05-25 07:10:09 -07:00
Takashi Kokubun
b83119be9e
Incremental syntax highlight for IRB source lines
Closes: https://github.com/ruby/ruby/pull/2202
2019-05-24 23:54:52 -07:00
Takashi Kokubun
32ed85f601
Copy config to make IRB::Context#use_colorize? functional
on initialize

This fixes https://github.com/ruby/ruby/pull/2188
2019-05-21 04:32:17 -07:00
aycabta
be0d9c0d26 Add "require 'irb'" to use IRB.conf 2019-05-21 09:24:09 +09:00
aycabta
94b740b249 Use Ripper for IRB
The debug option of IRB is deleted because it's just for IRB's pure Ruby
parser.
2019-04-30 14:40:06 +09:00
Takashi Kokubun
f2d7ba6a74
make sync-default-gems GEM=irb
from e8e79d569e.

This colorizes Range object on IRB inspect.
2019-04-28 21:51:37 +09:00
Takashi Kokubun
8711f77a26
make sync-default-gems GEM=irb
from 96f05e7268.

Just syncing newer test changes so that conflicts do not happen when trunk is
modified and we need to backport that to ruby/irb.
2019-04-28 20:34:11 +09:00
Takashi Kokubun
588f212c26
make sync-default-gems GEM=irb
from 44301d3827.

This includes some fixes for string interpolation highlight fixes.
2019-04-28 20:18:45 +09:00
git
ed4f331879 * remove trailing spaces. 2019-04-28 02:02:30 +09:00
Takashi Kokubun
cae0b73214
make sync-default-gems GEM=irb
from 89e9add06d.

This adds syntax highlight support for Module on inspect.

In addition to that, I'm adding a trailing space in test_color.rb for
testing ruby-commit-hook's auto-style.
2019-04-28 02:01:04 +09:00
Takashi Kokubun
9348643575
make sync-default-gems GEM=irb
Synced from 5feb361ed8.
This includes a support to colorize named Class instance on IRB inspect.
2019-04-27 22:01:11 +09:00
Takashi Kokubun
569c1ef6f1
make sync-default-gems GEM=irb
Backport changes from ruby/irb.
2019-04-27 11:42:40 +09:00
naruse
782e487260
suppress warning in test/irb
https://rubyci.org/logs/rubyci.s3.amazonaws.com/centos7/ruby-trunk/log/20190421T040003Z.fail.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Re-committing 7f09b5e9da
2019-04-27 11:31:30 +09:00
Takashi Kokubun
a429b3601f
Revert "Class instance should be also colorable on IRB"
This reverts commit 6669c966d2.

It seems to make tests fail... let me fix this later.
2019-04-26 18:46:43 +09:00
Takashi Kokubun
6669c966d2
Class instance should be also colorable on IRB
inspect.

Change is made with: `$ make -C .ruby sync-default-gems GEM=irb`
2019-04-26 18:42:51 +09:00
Takashi Kokubun
52cfb17086
make sync-default-gems GEM=irb
from e6739d8c66
2019-04-26 18:28:57 +09:00