sebastiencs / company-box

A company front-end with icons
561 stars 64 forks source link

frontend company-box-frontend error "Args out of range: 0, 16" on command show #135

Closed CsBigDataHub closed 3 years ago

CsBigDataHub commented 3 years ago

toggle-debug-on-error gives me

Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Args out of range: 0, 16" on command show
Debug on Error enabled globally
Entering debugger...
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show
CsBigDataHub commented 3 years ago

disabled (setq company-box-highlight-prefix t) referred in #123 to see if the error disappears but it still persists.

@seagle0128 can you please check if you are facing the same issue after the update?

seagle0128 commented 3 years ago

I didn't encounter this issue.

CsBigDataHub commented 3 years ago

Thanks @seagle0128

Just little bit more info -

pkg-version - company-box-20200920.1650 emacs-version - 27.1

error disappears when company-box config is commented-out/disabled and emacs is restarted.

company-box config -

(when emacs/>=26p
    (use-package company-box
      :diminish
      :defines company-box-icons-all-the-icons
      :hook (company-mode . company-box-mode)
      :init (setq company-box-enable-icon centaur-icon
                  company-box-backends-colors nil
                  company-box-highlight-prefix t
                  )
      :config
      (with-no-warnings
        ;; Prettify icons
        (defun my-company-box-icons--elisp (candidate)
          (when (derived-mode-p 'emacs-lisp-mode)
            (let ((sym (intern candidate)))
              (cond ((fboundp sym) 'Function)
                    ((featurep sym) 'Module)
                    ((facep sym) 'Color)
                    ((boundp sym) 'Variable)
                    ((symbolp sym) 'Text)
                    (t . nil)))))
        (advice-add #'company-box-icons--elisp :override #'my-company-box-icons--elisp))

      (when (icons-displayable-p)
        (declare-function all-the-icons-faicon 'all-the-icons)
        (declare-function all-the-icons-material 'all-the-icons)
        (declare-function all-the-icons-octicon 'all-the-icons)
        (setq company-box-icons-all-the-icons
              `((Unknown . ,(all-the-icons-material "find_in_page" :height 0.8 :v-adjust -0.15))
                (Text . ,(all-the-icons-faicon "text-width" :height 0.8 :v-adjust -0.02))
                (Method . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
                (Function . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
                (Constructor . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
                (Field . ,(all-the-icons-octicon "tag" :height 0.85 :v-adjust 0 :face 'all-the-icons-lblue))
                (Variable . ,(all-the-icons-octicon "tag" :height 0.85 :v-adjust 0 :face 'all-the-icons-lblue))
                (Class . ,(all-the-icons-material "settings_input_component" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-orange))
                (Interface . ,(all-the-icons-material "share" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
                (Module . ,(all-the-icons-material "view_module" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
                (Property . ,(all-the-icons-faicon "wrench" :height 0.8 :v-adjust -0.02))
                (Unit . ,(all-the-icons-material "settings_system_daydream" :height 0.8 :v-adjust -0.15))
                (Value . ,(all-the-icons-material "format_align_right" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
                (Enum . ,(all-the-icons-material "storage" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-orange))
                (Keyword . ,(all-the-icons-material "filter_center_focus" :height 0.8 :v-adjust -0.15))
                (Snippet . ,(all-the-icons-material "format_align_center" :height 0.8 :v-adjust -0.15))
                (Color . ,(all-the-icons-material "palette" :height 0.8 :v-adjust -0.15))
                (File . ,(all-the-icons-faicon "file-o" :height 0.8 :v-adjust -0.02))
                (Reference . ,(all-the-icons-material "collections_bookmark" :height 0.8 :v-adjust -0.15))
                (Folder . ,(all-the-icons-faicon "folder-open" :height 0.8 :v-adjust -0.02))
                (EnumMember . ,(all-the-icons-material "format_align_right" :height 0.8 :v-adjust -0.15))
                (Constant . ,(all-the-icons-faicon "square-o" :height 0.8 :v-adjust -0.1))
                (Struct . ,(all-the-icons-material "settings_input_component" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-orange))
                (Event . ,(all-the-icons-octicon "zap" :height 0.8 :v-adjust 0 :face 'all-the-icons-orange))
                (Operator . ,(all-the-icons-material "control_point" :height 0.8 :v-adjust -0.15))
                (TypeParameter . ,(all-the-icons-faicon "arrows" :height 0.8 :v-adjust -0.02))
                (Template . ,(all-the-icons-material "format_align_left" :height 0.8 :v-adjust -0.15)))
              company-box-icons-alist 'company-box-icons-all-the-icons))))
CsBigDataHub commented 3 years ago

Can confirm that it is working fine until pkg-version - company-box-20200829.1524

commit - adcb52b71f447e27493c4c98ad1d1711639f6e10

sebastiencs commented 3 years ago

@CsBigDataHub Does https://github.com/sebastiencs/company-box/commit/7696cebf6b87a80fbd45216fa2e7735e879af2c4 fix your issue ?

seagle0128 commented 3 years ago

@sebastiencs Now it looks like below. Is it as designed? I just want to highlight the prefix. how to make it?

image

CsBigDataHub commented 3 years ago

Thanks @sebastiencs, but that did not work for me either.

this is what I see when I do M-x toggle-debug-on-error

using pkg-version - company-box-20200927.539

commit - 7696cebf6b87a80fbd45216fa2e7735e879af2c4

Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Args out of range: 1, 3" on command show
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Args out of range: 0, 13" on command show
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Args out of range: 0, 31" on command show
Debug on Error enabled globally
Entering debugger...
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show

using pkg-version - company-box-20200927.1457

latest commit

Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show
Entering debugger...
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show

Only difference I have noticed is that the error message for both the commits/versions is different before I triggered M-x toggle-debug-on-error. As you can see above. Again company-mode is working fine if company-box is disabled.

just adding reference to my-config if you want to have a look - https://github.com/CsBigDataHub/.emacs.d-centaur/blob/my-personal/lisp/init-company.el

lsiksous commented 3 years ago

exact same problem for me with 26.3

sebastiencs commented 3 years ago

@CsBigDataHub Can you set debug-ignored-errors to nil and reproduce the issue with M-x toggle-debug-on-error ?

@seagle0128 Unfortunately highlighting the prefix only is not possible since https://github.com/sebastiencs/company-box/commit/1ff1297dd03eb4ede7dfde509d7e4235e00b2f63 company-box now relies on company-fill-propertize. This feature should be implemented in company-mode

CsBigDataHub commented 3 years ago

debug-ignored-errors has been set to nil.

image

yet do not see any difference in the messages buffer, same messages as earlier

Entering debugger...
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show
Entering debugger...
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show
Entering debugger...
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show
Entering debugger...
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show
Entering debugger...
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show
Entering debugger...
Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Invalid alignment size -14, aborting" on command show

@lsiksous Can you also try it and see if you see the same. Thanks

sebastiencs commented 3 years ago

@CsBigDataHub Can you try to recompile company-box:

(byte-recompile-directory (file-name-directory (find-library-name "company-box")) 0 t)

Does the issue always occur or under certain conditions ? What is your emacs version ? Which OS ?

I tried your full emacs configuration but it throws lots of error, so I couldn't test it

CsBigDataHub commented 3 years ago

@CsBigDataHub Can you try to recompile company-box:

(byte-recompile-directory (file-name-directory (find-library-name "company-box")) 0 t)

Does the issue always occur or under certain conditions ? What is your emacs version ? Which OS ?

I tried your full emacs configuration but it throws lots of error, so I couldn't test it

Emacs 27.1 compiled from emacs-plus on Macos Catalina for work. Emacs 27.1 compiled from source on Kubuntu at home.

Same error in both the instances.

Yes. My configuration has few submodules and some executables that I did not check in to github.

Also in both instances company-box is working fine until company-box-20200829.1524

sebastiencs commented 3 years ago

@CsBigDataHub Looks like the error comes from shackle: https://github.com/wasamasa/shackle/blob/master/shackle.el#L412 I see that you configured it with some advices, can you try to completely disable that package ?

seagle0128 commented 3 years ago

@seagle0128 Unfortunately highlighting the prefix only is not possible since 1ff1297 company-box now relies on company-fill-propertize. This feature should be implemented in company-mode

Thanks for update, @sebastiencs . But in company-mode, it looks like this. image

sebastiencs commented 3 years ago

@seagle0128 Ah sorry I misunderstood your issue. Does https://github.com/sebastiencs/company-box/commit/09f90d8c1151121d704d93e4e3149e464441c9ba fix it ?

sebastiencs commented 3 years ago

@CsBigDataHub Can you try https://github.com/sebastiencs/company-box/commit/405a7b7991228dba433938351e9296c4d899f86f, see if it fix your issue. If not, please disable shackle and test again, as the error come from that package.

seagle0128 commented 3 years ago

@seagle0128 Ah sorry I misunderstood your issue. Does 09f90d8 fix it ?

It does work now. Thanks a lot!

CsBigDataHub commented 3 years ago

@sebastiencs Thanks for your effort again.

He is what I have done.

  1. Disabled shackle.
  2. Updated company-box to company-box-20201003.725

Here is the error in the messages buffer

 Company: An error occurred in auto-begin
Company: frontend company-box-frontend error "Args out of range: 0, 5" on command show

Here is the back-trace after enabling toggle-debug-on-error

Debugger entered--Lisp error: (args-out-of-range 0 3)
  put-text-property(0 3 face (company-tooltip-selection company-tooltip) #("eq" 0 2 (face (company-tooltip) mouse-face (company-tooltip-mouse))))
  font-lock--add-text-property(0 3 face company-tooltip-selection #("eq" 0 2 (face (company-tooltip) mouse-face (company-tooltip-mouse))) nil)
  font-lock-prepend-text-property(0 3 face company-tooltip-selection #("eq" 0 2 (face (company-tooltip) mouse-face (company-tooltip-mouse))))
  company-fuzzy--company-fill-propertize(#f(compiled-function (value annotation width selected left right) #<bytecode 0x15838895ee5d>) #("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) nil 2 nil nil nil)
  apply(company-fuzzy--company-fill-propertize #f(compiled-function (value annotation width selected left right) #<bytecode 0x15838895ee5d>) (#("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) nil 2 nil nil nil))
  company-fill-propertize(#("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) nil 2 nil nil nil)
  company-box--candidate-string(#("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) 2)
  company-box--make-line((#("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) "<capf>" 2 6 company-fuzzy-all-other-backends))
  apply(company-box--make-line (#("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) "<capf>" 2 6 company-fuzzy-all-other-backends))
  #f(compiled-function (fn xs) #<bytecode 0x15838858b3b9>)(company-box--make-line ((#("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) "<capf>" 2 6 company-fuzzy-all-other-backends)))
  -reduce-r-from(#f(compiled-function (fn xs) #<bytecode 0x15838858b3b9>) (#("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) (company-box--make-line company-box--make-candidate))
  #f(compiled-function (&rest args) #<bytecode 0x158387a1fa05>)(#("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))))
  mapcar(#f(compiled-function (&rest args) #<bytecode 0x158387a1fa05>) [#("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) #("exp" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) #("ert" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) #("erc" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) #("eql" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) #("eol" 0 3 (yas-annotation "end-of-line" yas-template #s(yas--template :key "eol" :content "(end-of-line)" :name "end-of-line" :condition nil :expand-env nil :load-file "/home/mypc/.emacs.d/straight/build/yasnippet-snipp..." :save-file nil :keybinding nil :uuid "end-of-line" :menu-binding-pair ((menu-item "end-of-line" (lambda nil ... ...) :keys "eol =>")) :group nil :perm-group nil :table #s(yas--table :name "emacs-lisp-mode" :hash #<hash-table equal 114/145 0x15838c4f81d5> :uuidhash #<hash-table equal 118/145 0x15838c4f84ad> :parents nil :direct-keymap (keymap))) yas-prefix-offset 1)) #("elt" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) #("efn" 0 3 (yas-annotation "expand-file-name" yas-template #s(yas--template :key "efn" :content "(expand-file-name $0)" :name "expand-file-name" :condition nil :expand-env nil :load-file "/home/mypc/.emacs.d/straight/build/yasnippet-snipp..." :save-file nil :keybinding nil :uuid "expand-file-name" :menu-binding-pair ((menu-item "expand-file-name" (lambda nil ... ...) :keys "efn =>")) :group nil :perm-group nil :table #s(yas--table :name "emacs-lisp-mode" :hash #<hash-table equal 114/145 0x15838c4f81d5> :uuidhash #<hash-table equal 118/145 0x15838c4f84ad> :parents nil :direct-keymap (keymap))) yas-prefix-offset 1)) #("edt" 0 3 (yas-annotation "ert-deftest" yas-template #s(yas--template :key "edt" :content "(ert-deftest ${1:test-name} ()\n  $0)\n" :name "ert-deftest" :condition nil :expand-env nil :load-file "/home/mypc/.emacs.d/straight/build/yasnippet-snipp..." :save-file nil :keybinding nil :uuid "ert-deftest" :menu-binding-pair ((menu-item "ert-deftest" (lambda nil ... ...) :keys "edt =>")) :group nil :perm-group nil :table #s(yas--table :name "emacs-lisp-mode" :hash #<hash-table equal 114/145 0x15838c4f81d5> :uuidhash #<hash-table equal 118/145 0x15838c4f84ad> :parents nil :direct-keymap (keymap))) yas-prefix-offset 1)) #("eww" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) #("expt" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference))) "even" #("eval" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))])
  company-box--render-lines(1)
  company-box--move-selection(t)
  company-box--display(#("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n..." 0 1 (company-box-candidate #("eq" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 1 2 (company-box-candidate #("exp" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 2 3 (company-box-candidate #("ert" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 3 4 (company-box-candidate #("erc" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 4 5 (company-box-candidate #("eql" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 5 6 (company-box-candidate #("eol" 0 3 (yas-annotation "end-of-line" yas-template #s(yas--template :key "eol" :content "(end-of-line)" :name "end-of-line" :condition nil :expand-env nil :load-file "/home/mypc/.emacs.d/straight/build/yasnippet-snipp..." :save-file nil :keybinding nil :uuid "end-of-line" :menu-binding-pair ((menu-item "end-of-line" ... :keys "eol =>")) :group nil :perm-group nil :table #s(yas--table :name "emacs-lisp-mode" :hash #<hash-table equal 114/145 0x15838c4f81d5> :uuidhash #<hash-table equal 118/145 0x15838c4f84ad> :parents nil :direct-keymap (keymap))) yas-prefix-offset 1))) 6 7 (company-box-candidate #("elt" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 7 8 (company-box-candidate #("efn" 0 3 (yas-annotation "expand-file-name" yas-template #s(yas--template :key "efn" :content "(expand-file-name $0)" :name "expand-file-name" :condition nil :expand-env nil :load-file "/home/mypc/.emacs.d/straight/build/yasnippet-snipp..." :save-file nil :keybinding nil :uuid "expand-file-name" :menu-binding-pair ((menu-item "expand-file-name" ... :keys "efn =>")) :group nil :perm-group nil :table #s(yas--table :name "emacs-lisp-mode" :hash #<hash-table equal 114/145 0x15838c4f81d5> :uuidhash #<hash-table equal 118/145 0x15838c4f84ad> :parents nil :direct-keymap (keymap))) yas-prefix-offset 1))) 8 9 (company-box-candidate #("edt" 0 3 (yas-annotation "ert-deftest" yas-template #s(yas--template :key "edt" :content "(ert-deftest ${1:test-name} ()\n  $0)\n" :name "ert-deftest" :condition nil :expand-env nil :load-file "/home/mypc/.emacs.d/straight/build/yasnippet-snipp..." :save-file nil :keybinding nil :uuid "ert-deftest" :menu-binding-pair ((menu-item "ert-deftest" ... :keys "edt =>")) :group nil :perm-group nil :table #s(yas--table :name "emacs-lisp-mode" :hash #<hash-table equal 114/145 0x15838c4f81d5> :uuidhash #<hash-table equal 118/145 0x15838c4f84ad> :parents nil :direct-keymap (keymap))) yas-prefix-offset 1))) 9 10 (company-box-candidate #("eww" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 10 11 (company-box-candidate #("expt" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 11 12 (company-box-candidate "even") 12 13 (company-box-candidate #("eval" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 13 14 (company-box-candidate #("esup" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 14 15 (company-box-candidate #("eolp" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) 15 16 (company-box-candidate #("eobp" 0 1 (face (completions-common-part)) 1 2 (face (completions-first-difference)))) ...) nil)
  company-box-show()
  company-box-frontend(show)
  company-call-frontends(show)
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-idle-begin(#<buffer *scratch*> #<window 3 on *scratch*> 374 1426)
  apply(company-idle-begin (#<buffer *scratch*> #<window 3 on *scratch*> 374 1426))
  timer-event-handler([t 24440 65324 261999 nil company-idle-begin (#<buffer *scratch*> #<window 3 on *scratch*> 374 1426) nil 980000])
  read-event(nil t 3)
  sit-for(3)
  flyspell-check-word-p()
  flyspell-post-command-hook()
sebastiencs commented 3 years ago

@CsBigDataHub It should be fixed with https://github.com/sebastiencs/company-box/commit/be37a9a30dc112ab172af21af694e2cb04a74f85

Can you try again with shackle ? See if the error "Invalid alignment size -14, aborting" still occurs

CsBigDataHub commented 3 years ago

@sebastiencs Thanks for the support. Enabled shackle and everything is working as intended.

Closing the issue.