Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add insert at cursor functionality with tooltip #4936

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aadarshkt
Copy link
Contributor

@aadarshkt aadarshkt commented Apr 1, 2025

Description

Fixes : #4890
Added insert at cursor with help of existing codebase.

Checklist

  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screenshots

Screenshot 2025-04-01 at 23 53 27 Screenshot 2025-04-01 at 23 53 38

Testing instructions

[ For new or modified features, provide step-by-step testing instructions to validate the intended behavior of the change, including any relevant tests to run. ]

@aadarshkt aadarshkt requested a review from a team as a code owner April 1, 2025 18:24
@aadarshkt aadarshkt requested review from tomasz-stefaniak and removed request for a team April 1, 2025 18:24
Copy link

netlify bot commented Apr 1, 2025

Deploy Preview for continuedev canceled.

Name Link
🔨 Latest commit 17bf5b7
🔍 Latest deploy log https://app.netlify.com/sites/continuedev/deploys/67ef62ac8b07140008169223

@Patrick-Erichsen
Copy link
Collaborator

Patrick-Erichsen commented Apr 3, 2025

Thanks for taking this on @aadarshkt !

Some thoughts on the layout here:

  • Of the three options, apply is what we want to push people towards
  • Copy/Insert at cursor are both essentially backups

With that in mind, I think the following UI would work well:

  • Order of the buttons, from left to right, is "Copy", "Insert at cursor", "Apply"
  • Only "Apply" gets a label, "Copy" and "Insert at cursor" are both just icon buttons
  • Unrelated to ordering, but let's keep the tooltip position as "above" since the "Insert at cursor" is no longer the far-right option

If we go this route, we should probably re-order the the other action buttons (can't recall where they are in the GUI folder) to also follow this same order (see screenshot below)

Screenshot 2025-04-03 at 9 02 15 AM

Lmk your thoughts 👍

@Patrick-Erichsen Patrick-Erichsen self-requested a review April 3, 2025 16:05
@aadarshkt
Copy link
Contributor Author

@Patrick-Erichsen, Thanks for the review,

Yeah seems right to me as well, users will remember more what was first and last in the icon list, thus it is better to keep frequently used icons there.

I will make a change at both places.

@aadarshkt
Copy link
Contributor Author

aadarshkt commented Apr 4, 2025

Made an update in the UI,
Screenshot 2025-04-04 at 10 06 49

Will look into tooltipplacement, it is controlled by global state it seems.

Comment on lines +89 to +93
const uiConfig = useAppSelector(selectUIConfig);
const isBottomToolbarPosition =
uiConfig?.codeBlockToolbarPosition == "bottom";

const toolTipPlacement = isBottomToolbarPosition ? "top" : "bottom";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is all of this logic necessary given that the toolbar position is either top or bottom?
https://github.com/aadarshkt/continue/blob/fix-insert-at-cursor/core/index.d.ts#L1099

How about something like the following instead?

              <HeaderButtonWithToolTip
                text="Insert at cursor"
                style={{ backgroundColor: vscEditorBackground }}
                onClick={() =>
                  ideMessenger.post("insertAtCursor", {
                    text: codeBlockContent,
                  })
                }
                tooltipPlacement={uiConfig?.codeBlockToolbarPosition ?? "top"}
              >

@Patrick-Erichsen Patrick-Erichsen removed their request for review April 7, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bring back "Insert at cursor" on the new codeblock tool bar
3 participants