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

Change TextDocument's getText to take an optional range #298

Merged
merged 1 commit into from
Jan 10, 2018

Conversation

rcjsuen
Copy link
Contributor

@rcjsuen rcjsuen commented Dec 25, 2017

I've changed TextDocument so that its getText() function is now a getText(range?: Range). This fixes #255 and allows a client to extract a substring from the document instead of the entire range. If any positions are detected to be outside the bounds of the document (an offset less than zero or an offset greater than the length of the document), they will be adjusted to accordingly to fit within the bounds of the document.

object88 pushed a commit to object88/vscode-languageserver-node that referenced this pull request Dec 28, 2017
object88 pushed a commit to object88/vscode-languageserver-node that referenced this pull request Dec 28, 2017
@dbaeumer
Copy link
Member

dbaeumer commented Jan 8, 2018

@aeschli can you please review and follow up?

TextDocument's getText() function has been changed to take an
optional range in the form of getText(range?: Range). This allows
clients to extract a substring within the document instead of the
entire document. Ranges that start at a position smaller than the
document will be adjusted to the beginning of the document. Likewise,
ranges that end beyond the length of the document will be adjusted to
end within the bounds of the document.

Signed-off-by: Remy Suen <remy.suen@gmail.com>
@aeschli
Copy link
Contributor

aeschli commented Jan 10, 2018

I'm fine with the change. What is to be fixed is the specification of special cases:

  • Start & end positions outside of text content.
  • Start position after end position

I'll add that.

@aeschli aeschli merged commit 305cec2 into microsoft:master Jan 10, 2018
@aeschli aeschli added this to the January 2018 milestone Jan 10, 2018
@rcjsuen rcjsuen deleted the getText branch January 10, 2018 14:27
@rcjsuen
Copy link
Contributor Author

rcjsuen commented Jan 10, 2018

Thank you for taking the time to look at this, Martin!

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

Successfully merging this pull request may close these issues.

TextDocument.getText() should accept Range as an optional parameter
3 participants