Skip to content

Commit

Permalink
Fix #24, Fix #29
Browse files Browse the repository at this point in the history
  • Loading branch information
formulahendry committed Jun 18, 2017
1 parent 4b7f04b commit db0920c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 0.0.13 (2017-06-18)
* Fix [#24](https://github.com/formulahendry/vscode-auto-rename-tag/issues/24) and [#29](https://github.com/formulahendry/vscode-auto-rename-tag/issues/29)

### 0.0.12 (2017-05-21)
* Fix [#15](https://github.com/formulahendry/vscode-auto-rename-tag/issues/15) and [#21](https://github.com/formulahendry/vscode-auto-rename-tag/issues/21): Undo and redo are broken

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "auto-rename-tag",
"displayName": "Auto Rename Tag",
"description": "Auto rename paired HTML/XML tag",
"version": "0.0.12",
"version": "0.0.13",
"publisher": "formulahendry",
"icon": "images/logo.png",
"engines": {
Expand Down
9 changes: 7 additions & 2 deletions src/tagManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export class TagManager {
}

private getWordAtPosition(document: vscode.TextDocument, position: vscode.Position): string {
if (position.line > document.lineCount) {
return null;
}

let textLine = document.lineAt(position);
let text = textLine.text;
let regex = /[<\/]([a-zA-Z][a-zA-Z0-9-_:.]*)?[\s>]/g;
Expand Down Expand Up @@ -76,7 +80,8 @@ export class TagManager {
}

private updatePairedTag(event: vscode.TextDocumentChangeEvent): void {
if (!this.isEnabled() || /\r|\n/.test(event.contentChanges[0].text) || !event.contentChanges[0].range.isSingleLine) {
if (!this.isEnabled() || !event.contentChanges[0] ||
/\r|\n/.test(event.contentChanges[0].text) || !event.contentChanges[0].range.isSingleLine) {
return;
}

Expand Down Expand Up @@ -174,7 +179,7 @@ export class TagManager {

editor.edit((editBuilder) => {
editBuilder.replace(new vscode.Range(document.positionAt(pairedTag.startOffset), document.positionAt(pairedTag.endOffset)), newTag.word);
}, {undoStopBefore: false, undoStopAfter: false})
}, { undoStopBefore: false, undoStopAfter: false })

if (newTag.word === "") {
this._word = "";
Expand Down

0 comments on commit db0920c

Please sign in to comment.