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

fixes #1327 #1331

Merged
merged 3 commits into from
Feb 26, 2017
Merged
Changes from all 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
13 changes: 8 additions & 5 deletions src/matching/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import * as vscode from 'vscode';
* instances of the pair.
*/
export class PairMatcher {
static pairings: { [key: string]: { match: string, nextMatchIsForward: boolean, matchesWithPercentageMotion?: boolean }} = {
static pairings: {
[key: string]:
{ match: string, nextMatchIsForward: boolean, directionLess?: boolean, matchesWithPercentageMotion?: boolean }
} = {
"(" : { match: ")", nextMatchIsForward: true, matchesWithPercentageMotion: true },
"{" : { match: "}", nextMatchIsForward: true, matchesWithPercentageMotion: true },
"[" : { match: "]", nextMatchIsForward: true, matchesWithPercentageMotion: true },
Expand All @@ -19,9 +22,9 @@ export class PairMatcher {
">" : { match: "<", nextMatchIsForward: false },
// These are useful for deleting closing and opening quotes, but don't seem to negatively
// affect how text objects such as `ci"` work, which was my worry.
'"' : { match: '"', nextMatchIsForward: false },
"'" : { match: "'", nextMatchIsForward: false },
"`" : { match: "`", nextMatchIsForward: false },
'"': { match: '"', nextMatchIsForward: false, directionLess: true },
"'": { match: "'", nextMatchIsForward: false, directionLess: true },
"`": { match: "`", nextMatchIsForward: false, directionLess: true },
};

static nextPairedChar(position: Position, charToMatch: string, closed: boolean = true): Position | undefined {
Expand All @@ -38,7 +41,7 @@ export class PairMatcher {
*/
const toFind = this.pairings[charToMatch];

if (toFind === undefined) {
if (toFind === undefined || toFind.directionLess) {
return undefined;
}

Expand Down