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

Reset cursor to approximate source position after reformatting in SSMS, VS and NPP #96

Closed
TaoK opened this issue Apr 9, 2013 · 1 comment

Comments

@TaoK
Copy link
Owner

TaoK commented Apr 9, 2013

Algorithm something like this:

  • Determine the position of the start of the selection (start point)
  • Determine the position of the end of the selection (end point)
  • Determine the length of the selection (end point - start point = original length)
  • Determine the position of the cursor within the selection, in characters (original pos)
  • Get the formatted content to replace the selection
  • Determine the length of the new content (new length)
  • Determine the new position within the selection (new length * original pos / original length = new pos)
  • Replace the selection
  • Place the cursor at the required position (adding the "start point" to the "new pos" value to get the absolute position within the window content)

Suggested by Paul

@steelwil
Copy link

or

  • go to end of current line
  • put in a special comment saving the your current cursor position--$$PoorMansBookmark@Colum-nn$$
  • Format the document
  • go to the special comment and get the cursor column position
  • remove the special comment
  • go to your previous column

TaoK added a commit that referenced this issue Oct 20, 2013
…sition after a full document reformat in SSMS / VS
@TaoK TaoK closed this as completed Oct 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants