-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Add an API to get a terminal's selection #188173
Comments
I'll wait for this to go through the API sync before doing a test plan item. |
Proposal: If we want a change event: export namespace window {
export const onDidChangeTerminalSelection: Event<TerminalSelectionChangeEvent>;
}
export interface TerminalSelectionChangeEvent {
readonly terminal: Terminal;
readonly selection: string | undefined;
// No kind like TextEditorSelectionChangeKind
} |
Consider to have Also wondering about the missing "coordinates" (range, offset, etc) that would allow to locate and set selections |
@jrieken the part of the proposal already in main is |
Does that mean one isn't ever able to set a selection? How does this work internally. Does xterm not have this or do you simply not want to expose terminal rows/columns? |
You can select in xterm.js, here are the apis: select(column: number, row: number, length: number): void;
selectAll(): void;
selectLines(start: number, end: number): void; When considering whether we want to expose such an API it's useful to understand how the buffer works. It's essentially a big grid of characters of size
To bring this all together, we could of course expose xterm.js-like APIs in the exthost with the ability to pull and select arbitrary cell data, but it would have to be asynchronous and it would differ in subtle ways from the editor's APIs. Ultimately, I think this would just add APIs that don't add that much value but are easy to misuse, and the amount of value they add wouldn't be worth the effort to implement it anyway. |
Feedback:
|
I'd say that for the scope a proposed API this doesn't really matter. But for finalisation I wouldn't consider either, finalising an API so that it can be made obsolete in the future without hassle isn't a goal.
I don't know about this but my worry is that we do add more and more concepts to the terminal API, like selection or shell but that we don't think out load about the individual parts. We need to make sure that we don't miss the point at which we separate concerns and introduce types for buffer, buffer-coords, shell and more. I am not saying all needs to happen at once but for new API we must kept this in our mind and make sure we don't block any of this happening.
Agreeing and you can simulate that with cut-paste cycles of very many lines in a document. Tho, terminal-sync can be debounced to reduce waste. Again, not saying all of this must happen before proposing a simple selection but my worry is that we are getting closer to this inflection point at which we should have better decoupled bits. |
I'll keep this one on hold in its current proposed state for now, at least until the idea of a Terminal.shell API has been explored in #145234 |
Hey! Is there a workaround for this? Maybe executing the "copy" command and then reading clipboard? |
I would like to get the selected Text from Active Terminal in vscode extension |
@poornimas-iyer this isn't possible until there's more movement here and/or in #207504 |
I am hoping the same so that we can get selected text from active terminal. Looks like Copilot has already able to access this. Hoping there is some API can be exposed. |
@yuqizhou77 yeah when this went in for finalization it was put on hold along with some similar APIs as what we're ultimately moving towards is full buffer access in #207504, and we don't want to finalize an API that we don't want to keep as we generally don't break APIs. |
This is would be useful information for Copilot to know about.
The text was updated successfully, but these errors were encountered: