Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
TaoK opened this Issue · 1 comment

2 participants

@TaoK
Owner

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

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 TaoK referenced this issue from a commit
@TaoK Issue #96: Part 2 (final): Return to (approximate) previous cursor po…
…sition after a full document reformat in SSMS / VS
adfb367
@TaoK TaoK closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.