Fix N sentences

This commit is contained in:
rebornix 2016-06-27 15:29:20 +08:00
parent 3adbcb7801
commit 33e28c4c33
3 changed files with 10 additions and 4 deletions

View File

@ -79,8 +79,8 @@ Status | Command | Description
:white_check_mark: | :1234: B | N blank-separated |WORD|s backward
:white_check_mark: | :1234: ge | N words backward to the end of the Nth word
:white_check_mark: | :1234: gE | N words backward to the end of the Nth blank-separated |WORD|
| :1234: ) | N sentences forward
| :1234: ( | N sentences backward
:white_check_mark: | :1234: ) | N sentences forward
:white_check_mark: | :1234: ( | N sentences backward
:white_check_mark: | :1234: } | N paragraphs forward
:white_check_mark: | :1234: { | N paragraphs backward
| :1234: ]] | N sections forward, at start of section

View File

@ -501,7 +501,7 @@ export class Position extends vscode.Position {
for (let currentLine = this.line; currentLine >= paragraphBegin.line; currentLine--) {
let endPositions = this.getAllEndPositions(TextEditor.getLineAt(new vscode.Position(currentLine, 0)).text, regex);
let newCharacter = _.find(endPositions.reverse(),
index => ((index < this.character && !inclusive) ||
index => ((index < this.character && !inclusive && new Position(currentLine, index).getRightThroughLineBreaks().compareTo(this)) ||
(index <= this.character && inclusive)) || currentLine !== this.line)
if (newCharacter !== undefined) {
@ -509,7 +509,7 @@ export class Position extends vscode.Position {
}
}
if ((paragraphBegin.line + 1 === this.line || paragraphBegin.line === this.line) && this.character === 0) {
if ((paragraphBegin.line + 1 === this.line || paragraphBegin.line === this.line)) {
return paragraphBegin;
}
else {

View File

@ -416,6 +416,12 @@ suite("sentence motion", () => {
assert.equal(motion.character, 35);
});
test("sentence forward when cursor is at the beginning of the second sentence", () => {
let motion = new Position(0, 35).getPreviousSentenceBegin();
assert.equal(motion.line, 0);
assert.equal(motion.character, 0);
})
test("current sentence begin with no concrete sentense inside", () => {
let motion = new Position(3, 0).getPreviousSentenceBegin();
assert.equal(motion.line, 2);