origami.el
origami.el copied to clipboard
Collapse fails in ruby mode if the file contains single-line class.
Description :octocat:
I get an error when I fold the code in a ruby file that contains a single-line class, module, and method.
As a side note, in Ruby, classes, modules, and methods can each be defined in a single line, as shown below:
class Foo < Bar; end
module Baz; end
def foo; "hello" end
def bar() "hello" end
def foo(bar) = "hello" # since Ruby3.0
Reproduction guide :beetle:
- Start Emacs
- Open the following ruby file
class Foo < Bar; end
module Baz; end
def foo; "hello" end
def bar() "hello" end
def baz(v) = "hello"
- Run origami-close-all-nodes
Observed behaviour: :eyes: :broken_heart: (error "Offset is not within the range of the node: beg=1 ...")
Expected behaviour: :heart: :smile: No error in ruby file contains a single-line-definition
System Info :computer:
- OS: darwin
- Emacs: 27.1
- Spacemacs: 0.300.0
- Spacemacs branch: develop (rev. 37c8669d3)
- Graphic display: nil
- Distribution: spacemacs
- Editing style: vim
- Completion: helm
- Layers:
(emacs-lisp helm multiple-cursors treemacs)
- System configuration features: RSVG IMAGEMAGICK GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS XIM NS MODULES THREADS JSON PDUMPER LCMS2 GMP
Backtrace :paw_prints:
Debugger entered--Lisp error: (error "Offset is not within the range of the node: beg=1 ...")
signal(error ("Offset is not within the range of the node: beg=1 ..."))
error("Offset is not within the range of the node: beg=%s..." 1 0 20)
origami-fold-node(1 0 20 t nil nil)
#f(compiled-function (beg end offset children) #<bytecode 0x1fedf5cec791>)(1 0 20 nil)
#f(compiled-function (positions) #<bytecode 0x1fedf5ce467d>)(((#("class" 0 5 (face font-lock-keyword-face fontified t)) . 1) (#("end" 0 3 (face font-lock-keyword-face fontified t)) . 0) (#("module" 0 6 (face font-lock-keyword-face fontified t)) . 22) (#("end" 0 3 (face font-lock-keyword-face fontified t)) . 21) (#("def" 0 3 (face font-lock-keyword-face fontified t)) . 44) (#("end" 0 3 (face font-lock-keyword-face fontified t)) . 43) (#("def" 0 3 (face font-lock-keyword-face fontified t)) . 66) (#("end" 0 2 (face font-lock-keyword-face fontified t) 2 3 (face font-lock-keyword-face fontified t rear-nonsticky t)) . 65) (#("def" 0 3 (face font-lock-keyword-face fontified t)) . 88)))
origami-build-pair-tree(#f(compiled-function (beg end offset children) #<bytecode 0x1fedf5cec791>) "\\(s*def\\|class\\|module\\|if\\|unless\\|while\\|until\\|..." "\\(s*end\\)\\_>" "\\(s*else\\|when\\|elsif\\)\\_>" ((#("class" 0 5 (face font-lock-keyword-face fontified t)) . 1) (#("end" 0 3 (face font-lock-keyword-face fontified t)) . 0) (#("module" 0 6 (face font-lock-keyword-face fontified t)) . 22) (#("end" 0 3 (face font-lock-keyword-face fontified t)) . 21) (#("def" 0 3 (face font-lock-keyword-face fontified t)) . 44) (#("end" 0 3 (face font-lock-keyword-face fontified t)) . 43) (#("def" 0 3 (face font-lock-keyword-face fontified t)) . 66) (#("end" 0 2 (face font-lock-keyword-face fontified t) 2 3 (face font-lock-keyword-face fontified t rear-nonsticky t)) . 65) (#("def" 0 3 (face font-lock-keyword-face fontified t)) . 88)) #f(compiled-function (&rest _) #<bytecode 0x1fedf4cb7409>))
#f(compiled-function (content) #<bytecode 0x1fedf5cec7c9>)(#("class Foo < Bar; end\nmodule Foo < Bar; end\ndef foo..." 0 5 (face font-lock-keyword-face fontified t) 5 6 (fontified t) 6 9 (face font-lock-type-face fontified t) 9 12 (fontified t) 12 15 (face font-lock-type-face fontified t) 15 17 (fontified t) 17 20 (face font-lock-keyword-face fontified t) 20 21 (fontified t rear-nonsticky t) 21 27 (face font-lock-keyword-face fontified t) 27 28 (fontified t) 28 31 (face font-lock-type-face fontified t) 31 34 (fontified t) 34 37 (face font-lock-type-face fontified t) 37 39 (fontified t) 39 42 (face font-lock-keyword-face fontified t) 42 43 (fontified t rear-nonsticky t) ...))
#f(compiled-function (content) #<bytecode 0x1fedf5ce4341>)(#("class Foo < Bar; end\nmodule Foo < Bar; end\ndef foo..." 0 5 (face font-lock-keyword-face fontified t) 5 6 (fontified t) 6 9 (face font-lock-type-face fontified t) 9 12 (fontified t) 12 15 (face font-lock-type-face fontified t) 15 17 (fontified t) 17 20 (face font-lock-keyword-face fontified t) 20 21 (fontified t rear-nonsticky t) 21 27 (face font-lock-keyword-face fontified t) 27 28 (fontified t) 28 31 (face font-lock-type-face fontified t) 31 34 (fontified t) 34 37 (face font-lock-type-face fontified t) 37 39 (fontified t) 39 42 (face font-lock-keyword-face fontified t) 42 43 (fontified t rear-nonsticky t) ...))
origami-build-tree(#<buffer test.rb> #f(compiled-function (content) #<bytecode 0x1fedf5ce4341>))
origami-get-fold-tree(#<buffer test.rb>)
origami-close-all-nodes(#<buffer test.rb>)
funcall-interactively(origami-close-all-nodes #<buffer test.rb>)
call-interactively(origami-close-all-nodes nil nil)
command-execute(origami-close-all-nodes)