How to scroll the view after autocomplete is picked

Hi, This question is more of a sanity check to verify if i am doing it right. According to my understanding effects update transaction to produce sideeffects with the transaction

So to accomplish this, i am using below code as a “extension”

EditorState.transactionExtender.of((tr) => {
    if (tr.annotations.some((a) => a.type === pickedCompletion)) {
      return {
        effects: [EditorView.scrollIntoView(tr.newDoc.length)]
    return null;

Is this the right way to do it?

This is a way to force the editor to scroll to the bottom of the document every time a completion is picked. Whether that is a good idea is another question.

So if i find out the line where autocomplete was picked and scroll to end of that line…would that be a better solution?

You could do that, sure, or use scrollIntoView. But isn’t the cursor generally already in view when a completion is picked?

No it does not happen automatically for me. I might be able to provide sandbox if required (I am using python language extension but i dont think that might be relevant here). Also could you please share or point me to a one liner example of how to use scrollIntoView ?

No, I mean, what kind of situation makes this necessary? The completion suggestions pop up over the cursor. If you scroll that out of view the tooltip will become invisible, and the user cannoit pick a completion. What kind of workflow requires scrolling into view on picking a completion useful?

So when a codemirror has horizonatal scroll, and cursor is at the end of viewport when completion is picked up, it becomes necessary to bring the picked completion back into viewport

That makes sense. This patch adds that to the default behavior.

Thanks for this patch :smiley: