Comments (3)
Hey @mame!
I hit this same thing with ripper when I was writing prettier. I ended up solving it by taking the source, splitting it up into multiples lines, and converting each into an object that responded to #[]
so that I could get the right indices.
Here are some links to the source:
- https://github.com/prettier/plugin-ruby/blob/f6a4a6d4299a91692a8b1aa287103d1e7e887b18/src/ruby/parser.rb#L23-L54
- https://github.com/prettier/plugin-ruby/blob/f6a4a6d4299a91692a8b1aa287103d1e7e887b18/src/ruby/parser.rb#L104-L120
- https://github.com/prettier/plugin-ruby/blob/f6a4a6d4299a91692a8b1aa287103d1e7e887b18/src/ruby/parser.rb#L132-L139
I hope it's helpful!
from error_highlight.
Thanks for the information. I think it is about the issue (1) that I said. Yeah, it is solvable by converting the indices.
The tougher issue is (2). Unfortunately, some Unicode characters (mainly Chinese, Japanese, and Korean characters) are rendered as if they have two columns.
γ
is one Japanese letter that takes two columns in the terminal. To highlight the letter, we need to put two ^
s under the line. To implement this, error_highlight needs a table to tell what character takes two (or more) columns.
Just FYI: To make matters worse, the column count may change depending on a font and a terminal. This issue is called East Asian Width:
Ambiguous width characters are all those characters that can occur as fullwidth characters in any of a number of East Asian legacy character encodings. They have a βresolvedβ width of either narrow or wide depending on the context of their use.
To be honest, I don't want to face this problem for now π
from error_highlight.
@mame I see, I think I understand the problem better now. In that case it would probably be nice to have Ruby::AST::Node
have methods like {first,last}_character_column
or something similar.
from error_highlight.
Related Issues (16)
- Remove custom formatter HOT 1
- Tweak highlight range HOT 2
- Question: understanding strings appended to NoMethodError message upon raise HOT 5
- Bundle install hangs HOT 1
- ArgumentError#message changes since 0.5.0 HOT 3
- How about "known issues" document? HOT 4
- NameError column adjustment HOT 2
- Doesn't highlight error for missing constant when const_missing is redefined for class HOT 7
- Display a line in application code instead of gems
- Broken link
- Fails in Github Actions in Ruby 3.1.4 HOT 10
- Handle very long line well HOT 1
- Does not work in IRB
- Deal with hard tabs
- Handle a backslash well HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from error_highlight.