sebastiencs / company-box

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

`(wrong-type-argument integer-or-marker-p nil)` during completing Python function (with docs) #195

Closed real-or-random closed 1 year ago

real-or-random commented 1 year ago

emacs 29.0

Package versions:

  company                        20230303.2331  installed             Modular text completion framework
  company-box                    20221230.1603  installed             Company front-end with icons
  lsp-mode                       20230304.2108  dependency            LSP mode
  lsp-ui                         20230116.2024  dependency            UI modules for lsp-mode

Backtrace:

Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p nil)
  lsp-completion--company-match(#("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))))
  company-capf(match #("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))))
  apply(company-capf (match #("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)))))
  company-call-backend-raw(match #("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))))
  company--force-sync(company-call-backend-raw (match #("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)))) company-capf)
  company-call-backend(match #("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))))
  company--common-or-matches(#("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))))
  company-fill-propertize(#("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))) nil 18 nil nil nil)
  company-box--candidate-string(#("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))) 18)
  company-box--make-line((#("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))) "(Class)" 18 7 company-capf))
  #f(compiled-function (&rest args) #<bytecode 0x54e38c792f36db1>)(#("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data (0 3 0 1 1 2 2 3))) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))))
  company-box--render-lines(1)
  company-box--move-selection(t)
  company-box--display(#("\n\n\n" 0 1 (company-box-candidate #("TemporaryDirectory" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data ...)) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 18 (lsp-completion-item (:label #("TemporaryDirectory" 0 18 (match-data ...)) :kind 7 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory()" :data (:doc_uri "file:///home/[REDACTED].py")) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point nil lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)))) 1 2 (company-box-candidate #("TemporaryDirectory object" 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryDirectory object" 0 25 (match-data ...)) :kind 25 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory" :data (:doc_uri "file:///home/[REDACTED].py") :_emacsStartPoint 8012) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point 8012 lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 25 (lsp-completion-item (:label #("TemporaryDirectory object" 0 25 (match-data ...)) :kind 25 :sortText "aTemporaryDirectory" :insertText "TemporaryDirectory" :data (:doc_uri "file:///home/[REDACTED].py") :_emacsStartPoint 8012) lsp-sort-text "aTemporaryDirectory" lsp-completion-start-point 8012 lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)))) 2 3 (company-box-candidate #("TemporaryFile(mode, buffering, encoding, newline, ..." 0 1 (face (completions-first-difference) lsp-completion-item (:label #("TemporaryFile(mode, buffering, encoding, newline, ..." 0 78 (match-data ...)) :kind 3 :sortText "aTemporaryFile" :insertText "TemporaryFile($0)" :insertTextFormat 2 :data (:doc_uri "file:///home/[REDACTED].py") :_emacsStartPoint 8012) lsp-sort-text "aTemporaryFile" lsp-completion-start-point 8012 lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3)) 1 78 (lsp-completion-item (:label #("TemporaryFile(mode, buffering, encoding, newline, ..." 0 78 (match-data ...)) :kind 3 :sortText "aTemporaryFile" :insertText "TemporaryFile($0)" :insertTextFormat 2 :data (:doc_uri "file:///home/[REDACTED].py") :_emacsStartPoint 8012) lsp-sort-text "aTemporaryFile" lsp-completion-start-point 8012 lsp-completion-markers (8012 #<marker (moves after insertion) at 8015 in [REDACTED].py>) lsp-completion-prefix "Te" match-data (0 3 0 1 1 2 2 3))))) nil)
  company-box-show()
  company-box-frontend(show)
  company-call-frontends(show)
  company--begin-new()
  company--perform()
  company-auto-begin()
  company-idle-begin(#<buffer [REDACTED].py> #<window 3 on [REDACTED].py> 2170 8015)
  apply(company-idle-begin (#<buffer [REDACTED].py> #<window 3 on [REDACTED].py> 2170 8015))
  timer-event-handler([t 25607 11821 852407 nil company-idle-begin (#<buffer [REDACTED].py> #<window 3 on [REDACTED].py> 2170 8015) nil 426000 nil])
  sit-for(3)
  flyspell-check-word-p()
  flyspell-post-command-hook()
dchrzanowski commented 1 year ago

I have the same thing happening while using company-box while editing typescript files.

The issue can be replicated. Say that I have a class attribute called "pinnedUsers", so if I type this.pin in some method and stop there, C-g the company pop-up, and manually invoke company-complete-common (or move away the point and return it to just after this.pin and try start typing again).

The error I get is: Company: frontend company-box-frontend error "Company: backend company-capf error "Wrong type argument: integer-or-marker-p, nil" with args (match pinnedUsers)" on command show.

dgutov commented 1 year ago

Try disabling company-box-mode and using the built-in popup front-end. Is the problem the same then?

Sounds like it's an lsp-mode issue.

real-or-random commented 1 year ago

Try disabling company-box-mode and using the built-in popup front-end. Is the problem the same then?

The problem disappears when I do this, so I think this is really related to company-box.

dchrzanowski commented 1 year ago

Same for me, disabling company-box-mode gets rid of the problem. The error states that it is the company-box-frontend that is throwing an error. It is entirely possible that a recent update to the LSP package has caused this and company-box just needs to adapt to the change.

dgutov commented 1 year ago

Frontends are allowed to call into backends, and lsp-completion--company-match is at the end of the backtrace.

But if you only see the error with company-box, it could be doing something wrong indeed.

sebastiencs commented 1 year ago

@real-or-random @dchrzanowski I am not able to reproduce the issue. I agree with @dgutov, this seems like a lsp-mode issue to me. It's weird that it occurs only when company-box is enabled.

In the stacktrace I see lsp-completion-start-point nil, it shouldn't be a nil, and company-box does not modify that variable.

Could you please try to revert https://github.com/emacs-lsp/lsp-mode/commit/03e1818acae6de9a6ed89c54573f8050e4d4e463, see if it makes any difference ?

Alternatively, can you try to disable the doc with (setq company-box-doc-enable nil). My guess is that the value of lsp-completion-start-point might get lost when company-box pops new buffer/frames.

dgutov commented 1 year ago

Perhaps if lsp-completion-start-point's value is buffer-local, you might be querying it in a different buffer, thus getting an error?

(with-current-buffer ...) around the company-fill-propertize call could help. If that is indeed the problem.

sebastiencs commented 1 year ago

lsp-completion-start-point is a property on the candidate. In the stacktrace we can see that it's already nil before the call to company-fill-propertize: from the line company-box--display. So I don't think it's related to company-fill-buffer call.

I just checked further @real-or-random's stacktrace, on the line/call of company-box--display: We can see that only the 1st candidate does have a lsp-completion-start-point nil. The 2nd and 3rd candidates have a correct value lsp-completion-start-point 8012, they also have the property :_emacsStartPoint 8012, while the 1st candidate is missing it. The commit https://github.com/emacs-lsp/lsp-mode/commit/03e1818acae6de9a6ed89c54573f8050e4d4e463 looks suspicious to me. If someone could try to revert it locally.

That's probably an issue to open in the lsp-mode repository, or maybe @yyoncho can help here ?

vekatze commented 1 year ago

Hi. I also encountered this problem, and tried reverting emacs-lsp/lsp-mode@03e1818 locally as suggested. The problem went away after that. Everything works fine now. Hope this helps.

real-or-random commented 1 year ago

@sebastiencs Would you be willing to file a lsp-mode issue then? I think you're the one who can describe the problem best.

yyoncho commented 1 year ago

@sebastiencs Would you be willing to file a lsp-mode issue then? I think you're the one who can describe the problem best.

I will do a fix later today

yyoncho commented 1 year ago

@real-or-random just pushed a fix, you can test it out.

real-or-random commented 1 year ago

Awesome! I'm traveling, so I don't have the time to test it right now. But maybe @vekatze or @dchrzanowski are willing to test.

vekatze commented 1 year ago

I've upgraded lsp-mode and been trying it. Things are running great without any errors, at least on my environment. My Emacs world is peaceful again. Thank you for your fix, @yyoncho.

sebastiencs commented 1 year ago

Great. Thanks everyone