Skip to content

Commit

Permalink
Fix #12: Not work when using OPTION+DELETE (or CTRL+BACKSPACE)
Browse files Browse the repository at this point in the history
  • Loading branch information
formulahendry committed Dec 31, 2016
1 parent 9075ea7 commit 49fdf10
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 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.11
* Fix [GitHub issue#12](https://github.com/formulahendry/vscode-auto-rename-tag/issues/12): Not work when using OPTION+DELETE (or CTRL+BACKSPACE)

### 0.0.10
* Fix [GitHub issue#17](https://github.com/formulahendry/vscode-auto-rename-tag/issues/17): Unexpected renaming when moving row with "alt+down"

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.10",
"version": "0.0.11",
"publisher": "formulahendry",
"icon": "images/logo.png",
"engines": {
Expand Down
19 changes: 7 additions & 12 deletions src/tagManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,14 @@ export class TagManager {
let selection = editor.selection;

let cursorPositon = selection.active;
if (event.contentChanges[0].text === "" || !selection.start.isEqual(selection.end)) {
if (selection.start.isEqual(selection.end)) {
if (selection.start.character === 0) {
return;
}
cursorPositon = cursorPositon.translate(0, -1);
let rangeStart = event.contentChanges[0].range.start;
let rangeEnd = event.contentChanges[0].range.end;
if (!rangeStart.isEqual(rangeEnd)) {
// Handle deletion or update of multi-character
if (rangeStart.isBefore(rangeEnd)) {
cursorPositon = rangeStart;
} else {
// Handle deletion or update of multi-character
if (selection.start.isBefore(selection.end)) {
cursorPositon = selection.start;
} else {
cursorPositon = selection.end;
}
cursorPositon = rangeEnd;
}
}

Expand Down

0 comments on commit 49fdf10

Please sign in to comment.