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

Detect ghost text in PromptInputModel #210690

Merged
merged 4 commits into from
Apr 18, 2024
Merged

Detect ghost text in PromptInputModel #210690

merged 4 commits into from
Apr 18, 2024

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Apr 18, 2024

Fixes #210662

Ghost text will show up in brackets in the devmode status bar:

Recording 2024-04-18 at 11 32 29

I tested this on PowerShell but it should work on any shell that uses dim or italic as ghost text.

cc @cpendery

@Tyriar Tyriar added this to the April 2024 milestone Apr 18, 2024
@Tyriar Tyriar self-assigned this Apr 18, 2024
@Tyriar Tyriar enabled auto-merge April 18, 2024 18:32
@Tyriar Tyriar requested a review from meganrogge April 18, 2024 18:43
@Tyriar Tyriar merged commit 3be6cd6 into main Apr 18, 2024
6 checks passed
@Tyriar Tyriar deleted the tyriar/210662 branch April 18, 2024 18:53
@@ -122,9 +144,15 @@ export class PromptInputModel extends Disposable implements IPromptInputModel {
// Get cursor index
const absoluteCursorY = buffer.baseY + buffer.cursorY;
this._cursorIndex = absoluteCursorY === commandStartY ? this._getRelativeCursorIndex(this._commandStartX, buffer, line) : commandLine.length + 1;
this._ghostTextIndex = -1;

// Detect ghost text by looking for italic or dim text in or after the cursor and
Copy link
Contributor

Choose a reason for hiding this comment

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

this is cool, wouldn't have thought of this

@cpendery
Copy link
Member

This is how I've been detecting ghost text since I've seen variation between zsh-autocomplete, atuin, xonsh, etc. Might be helpful to augment _isCellStyledLikeGhostText with

https://github.com/microsoft/inshellisense/blob/a7219b18355f444ba6ed5c4322121b01b8c18291/src/isterm/commandManager.ts#L200-L212

@microsoft microsoft locked and limited conversation to collaborators Jun 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PromptInputModel: Try detect ghost text
4 participants