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

Fix pylintrc search #805

Merged
merged 5 commits into from
Feb 19, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/client/language/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,14 @@ export class Tokenizer implements ITokenizer {
}

private skipToSingleEndQuote(quote: number): void {
while (!this.cs.isEndOfStream() && this.cs.currentChar !== quote) {
while (!this.cs.isEndOfStream()) {
if (this.cs.currentChar === Char.Backslash && this.cs.nextChar === quote) {
this.cs.advance(2);
continue;
}
if (this.cs.currentChar === quote) {
break;
}
this.cs.moveNext();
}
this.cs.moveNext();
Expand Down
2 changes: 1 addition & 1 deletion src/client/linters/pylint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Pylint extends BaseLinter {
const settings = this.configService.getSettings(uri);
if (settings.linting.pylintUseMinimalCheckers
&& this.info.linterArgs(uri).length === 0
&& !await Pylint.hasConfigurationFile(this.fileSystem, uri.fsPath, this.platformService)) {
&& !await Pylint.hasConfigurationFile(this.fileSystem, this.getWorkspaceRootPath(document), this.platformService)) {

Choose a reason for hiding this comment

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

Its possible to have pylintrc next to the file itself, and not in the root directory. I don't think this would work under that scenario.

minArgs = [
'--disable=all',
'--enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode'
Expand Down
15 changes: 15 additions & 0 deletions src/test/language/tokenizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ suite('Language.Tokenizer', () => {
assert.equal(tokens.getItemAt(i).type, TokenType.String);
}
});
test('Strings: single quote escape', async () => {
const t = new Tokenizer();
// tslint:disable-next-line:quotemark
const tokens = t.tokenize("'\\'quoted\\''");
assert.equal(tokens.count, 1);
assert.equal(tokens.getItemAt(0).type, TokenType.String);
assert.equal(tokens.getItemAt(0).length, 12);
});
test('Strings: double quote escape', async () => {
const t = new Tokenizer();
const tokens = t.tokenize('"\\"quoted\\""');
assert.equal(tokens.count, 1);
assert.equal(tokens.getItemAt(0).type, TokenType.String);
assert.equal(tokens.getItemAt(0).length, 12);
});
test('Comments', async () => {
const t = new Tokenizer();
const tokens = t.tokenize(' #co"""mment1\n\t\n#comm\'ent2 ');
Expand Down