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

IModel.onDidChangeContent doesn't provide information about what was there before the change #72

Closed
ljw1004 opened this issue Jul 18, 2016 · 1 comment

Comments

@ljw1004
Copy link

ljw1004 commented Jul 18, 2016

Scenario:

  1. I have a content widget at line 9 in the file.
  2. The user types in a newline at line 3.
  3. I want to bump my content widget down one line, so it's still anchored to the same line in the file.

I've hooked into IModel.onDidChangeContent. That provides me IModelContentChangedEvent2 which has the original span, and the new text that has replaced what was there before. But that alone isn't enough for me to calculate the net change in number of lines caused by this event (hence, the number of lines that my existing content widgets must scroll by).

@ljw1004
Copy link
Author

ljw1004 commented Jul 18, 2016

Doh. Actually, I think it does provide enough information. I can look at range.endLineNumber - range.startLineNumber to count how many lines the original span encompassed, and I can use getPositionAtOffset to count how many lines the replacement text encompassed, and that's enough.

You always find the solution within 30 seconds of posting the question.

@ljw1004 ljw1004 closed this as completed Jul 18, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant