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

Selection Range support. Part of Microsoft/vscode#65925 #46

Merged
merged 3 commits into from
Jan 23, 2019

Conversation

octref
Copy link
Contributor

@octref octref commented Jan 23, 2019

No description provided.

@octref octref merged commit f17cb77 into master Jan 23, 2019

suite('HTML SelectionRange', () => {
test('Basic', () => {
assertRanges('<div|>foo</div>', [[1, 4], [0, 14]]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't [1,4] be [1,3]?
For readability, maybe format the expected ranges like [ "1:div", "0:<div>foo</div>"]

content = content.substr(0, offset) + content.substr(offset + 1);

const document = TextDocument.create('test://foo/bar.html', 'html', 1, content);
const actualRanges = getApplicableRanges(document, document.positionAt(offset));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally write the tests against the public API (htmlLanguageService.getSelectionRanges), that way we are sure it works end-to-end and the implementation can be changed freely without impacting any tests.

assertRanges('<div>foo</|div>', [[10, 13], [0, 14]]);
assertRanges('<div>foo</di|v>', [[10, 13], [0, 14]]);
assertRanges('<div>foo</div|>', [[10, 13], [0, 14]]);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also test self closed tags (<div foo="sdsdd"/>)

test('Multiple Attribute Value', () => {
assertRanges('<div class="foo" id="|bar">foo</div>', [[21, 24], [20, 25], [17, 25], [1, 25], [0, 35]]);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test comments and doctypes as well

@aeschli
Copy link
Contributor

aeschli commented Jan 24, 2019

Nice work!

@octref
Copy link
Contributor Author

octref commented Jan 24, 2019

@aeschli Thanks! Addressed all your comments.

@aeschli aeschli added this to the December/January 2019 milestone Jan 28, 2019
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.

2 participants