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

Get Position Of Curser - Reverse Of Going To A Position #2

Closed
sahin52 opened this issue Mar 4, 2022 · 5 comments
Closed

Get Position Of Curser - Reverse Of Going To A Position #2

sahin52 opened this issue Mar 4, 2022 · 5 comments

Comments

@sahin52
Copy link

sahin52 commented Mar 4, 2022

A feature request:
Going to character position is awesome, but it'd be nice to get the current position of cursor.

@soulshined
Copy link
Collaborator

@sahin52

Just making sure we are thinking about the same thing:

vscode does provide the position of a cursor at the bottom of the status bar where it says something like Ln 58, Col 31:

Screenshot 2022-03-04 165013

Col 31 would be the column of the cursor.

Are you talking about that or do you want the 'absolute index'? Like the 0 or 1 based character index in the text body?

@sahin52
Copy link
Author

sahin52 commented Mar 4, 2022

We can jump to a character position, by giving the number of exact position in that file with your extension. I want my exact position currently, not the line and column.
Let me show you what I mean:
I can go to a position (1234th char) with your extension like this:
image

And I have gone here:
image
For example when I didn't change my position after going to a position(1234) and if I want to get my position here, somehow I need to get 1234.

I didn't think how it would show, with a dialog box or something. I just would be happy if I get my position. It is important when dealing with files and texts in them.

@soulshined
Copy link
Collaborator

Great. Thanks for walkthrough and snapshots! Much appreciated. I think we are on the same page!

Getting a characters position is not a terribly complex task to do at all, however, if we are to take user experience into account, there's really only 2 ways I can think of that vscode api natively supports.

  1. Getting the position with an onkeypress-like event handler
  2. Getting the position using an interval timer (which I'm not particular excited about personally)

Both these options, at a high level, could potentially negatively impact editor performance and I would like to avoid that, if possible. Not to say that it will, just saying I don't know off the top of my head.

Worst case scenario, I can just add a command pallete command that the user will have to explicitly invoke, something along the lines of what you mentioned with a dialog box.

All this to say, it's doable, and I find value in adding it, I just want to make sure it's done in a way that doesn't have a negative experience as a byproduct so it won't be as fast as a turn-around as you would like I image. But let me explore those first 2 options and see how they impact typing performance, if at all, and go from there!

@soulshined
Copy link
Collaborator

This was easier than I anticipated @sahin52

Please udpate your extension to 2.0, review the changelog for details around it and provide feedback on if I should close this or not

@sahin52
Copy link
Author

sahin52 commented Mar 6, 2022

Thanks a lot, it seems quite okay. I personally would want a key press to see my current location, like for example when I press Ctrl+k Ctrl+g. I could see my current position under the dialog box when I could write the position that I want to go.
image
Here can show "Your current position is 123" for example under the input area.
But this version is completely okay as well, it is just my personal opinion. Thank a lot again.

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

No branches or pull requests

2 participants