0x2c7/ruby_jard

[BUG] Source output incorrect

hirowatari opened this issue ยท 2 comments

Describe the bug
Jard source output does not match what is the file.

To Reproduce
Steps to reproduce the behavior:

  1. Here's my file
    [jobs_controller.rb.txt] (https://github.com/nguyenquangminh0711/ruby_jard/files/5257455/jobs_controller.rb.txt)
    There's a comment in that file that explains things a bit more on line 68.
#snippet of actual file
      def index; end

      def create
        jard
        authorize Legacy::Job
        job = Legacy::Job.create!(legacy_user: current_user, legacy_collection: @collection,
                                  status: Legacy::Job.statuses[:pending], locations_file: params.fetch(:locations))
        import_job(job)
      rescue ActionController::ParameterMissing
        job&.destroy
  1. Run jard (in my case docker-compose exec rails bundle exec rspec
  2. Jard shows the file as with some output from a function at the bottom of the file:
    Screenshot from 2020-09-21 11-19-24

Expected behavior
Show the file correctly

Screenshots
works correctly on more narrow layout:
Screenshot from 2020-09-21 11-22-13

Environment (please complete the following information):

  • OS: [e.g. Ubuntu 20, MacOS Big Suck, FreeBSD]
uname -a
Linux inni 5.8.10-arch1-1 #1 SMP PREEMPT Thu, 17 Sep 2020 18:01:06 +0000 x86_64 GNU/Linux
  • Terminal Emulator [e.g Alacritty, Terminal.app (Mac's default one), GNOME Terminal (Ubuntu's default one), etc.]
    terminator 1.92
  • Output when you run tput colors in your terminal
    8
  • Output when you run echo $TERM in your terminal
    screen
  • Output when you run stty

speed 38400 baud; line = 0;
-brkint -imaxbel

  • Do you use tmux/screen or similar tty multiplexer?
    yes but issue exists without it as well.

Thanks a lot for Jard. It's beautiful.

0x2c7 commented

Hi @hirowatari, thanks for reporting this issue. I tested on my local environment, and confirmed that this happens. The root cause is from variable screen, instead. I forgot to escape special characters (\n in this case) from SQL before printing it out to the screen. So, it overlaps and breaks the source screen. I implemented a fix at #56, and already merged into master. You can try the fix at master branch first. I'll push a relase soon.

gem 'ruby_jard', git: 'https://github.com/nguyenquangminh0711/ruby_jard', ref: 'master'

@nguyenquangminh0711 Thanks!! That fixed it. Appreciate the quick fix.