[
  {
    "path": ".github/workflows/main.yml",
    "content": "name: CI\n\non:\n  push:\n    branches: [ master ]\n  pull_request:\n    branches: [ master ]\n\n  workflow_dispatch:\n\njobs:\n  build:\n    strategy:\n      fail-fast: false\n      matrix:\n        os: [macos-latest, ubuntu-latest, windows-latest]\n    runs-on: ${{ matrix.os }}\n\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v2\n      - name: Install Node.js\n        uses: actions/setup-node@v1\n        with:\n          node-version: 16.x\n      - run: npm install\n      - run: npm run vscode:prepublish\n"
  },
  {
    "path": ".gitignore",
    "content": "out\nnode_modules"
  },
  {
    "path": ".travis.yml",
    "content": "sudo: false\r\n\r\nos:\r\n  - osx\r\n  - linux\r\n\r\nbefore_install:\r\n  - if [ $TRAVIS_OS_NAME == \"linux\" ]; then\r\n      export CXX=\"g++-4.9\" CC=\"gcc-4.9\" DISPLAY=:99.0;\r\n      sh -e /etc/init.d/xvfb start;\r\n      sleep 3;\r\n    fi\r\n\r\ninstall:\r\n  - npm install\r\n  - npm run vscode:prepublish\r\n\r\nscript:\r\n  - npm test --silent"
  },
  {
    "path": ".vscode/launch.json",
    "content": "// A launch configuration that compiles the extension and then opens it inside a new window\n{\n    \"version\": \"0.1.0\",\n    \"configurations\": [\n        {\n            \"name\": \"Launch Extension\",\n            \"type\": \"extensionHost\",\n            \"request\": \"launch\",\n            \"runtimeExecutable\": \"${execPath}\",\n            \"args\": [\"--extensionDevelopmentPath=${workspaceRoot}\" ],\n            \"stopOnEntry\": false,\n            \"sourceMaps\": true,\n            \"outDir\": \"${workspaceRoot}/out/src\",\n            \"preLaunchTask\": \"npm\"\n        },\n        {\n            \"name\": \"Launch Tests\",\n            \"type\": \"extensionHost\",\n            \"request\": \"launch\",\n            \"runtimeExecutable\": \"${execPath}\",\n            \"args\": [\"--extensionDevelopmentPath=${workspaceRoot}\", \"--extensionTestsPath=${workspaceRoot}/out/test\" ],\n            \"stopOnEntry\": false,\n            \"sourceMaps\": true,\n            \"outDir\": \"${workspaceRoot}/out/test\",\n            \"preLaunchTask\": \"npm\"\n        }\n    ]\n}\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "// Place your settings in this file to overwrite default and user settings.\n{\n    \"files.exclude\": {\n        \"out\": false // set this to true to hide the \"out\" folder with the compiled JS files\n    },\n    \"search.exclude\": {\n        \"out\": true // set this to false to include \"out\" folder in search results\n    },\n    \"typescript.tsdk\": \"./node_modules/typescript/lib\" // we want to use the TS server from our node_modules folder to control its version\n}"
  },
  {
    "path": ".vscode/tasks.json",
    "content": "// Available variables which can be used inside of strings.\n// ${workspaceRoot}: the root folder of the team\n// ${file}: the current opened file\n// ${fileBasename}: the current opened file's basename\n// ${fileDirname}: the current opened file's dirname\n// ${fileExtname}: the current opened file's extension\n// ${cwd}: the current working directory of the spawned process\n\n// A task runner that calls a custom npm script that compiles the extension.\n{\n    \"version\": \"2.0.0\",\n\n    // we want to run npm\n    \"command\": \"npm\",\n\n    // we run the custom script \"compile\" as defined in package.json\n    \"args\": [\"run\", \"compile\", \"--loglevel\", \"silent\"],\n\n    // The tsc compiler is started in watching mode\n    \"isWatching\": true,\n\n    // use the standard tsc in watch mode problem matcher to find compile problems in the output.\n    \"problemMatcher\": \"$tsc-watch\",\n    \"tasks\": [\n        {\n            \"label\": \"npm\",\n            \"type\": \"shell\",\n            \"command\": \"npm\",\n            \"args\": [\n                \"run\",\n                \"compile\",\n                \"--loglevel\",\n                \"silent\"\n            ],\n            \"isBackground\": true,\n            \"problemMatcher\": \"$tsc-watch\",\n            \"group\": \"build\"\n        }\n    ]\n}"
  },
  {
    "path": ".vscodeignore",
    "content": ".vscode/**\ntypings/**\nout/test/**\ntest/**\nsrc/**\n**/*.map\n.gitignore\ntsconfig.json\nvsc-extension-quickstart.md\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "### 0.5.15 (2023-12-09)\r\n* [#222](https://github.com/formulahendry/vscode-auto-close-tag/pull/222): Fix for undo/redo\r\n\r\n### 0.5.14 (2022-02-08)\r\n* Add sponsor for Duckly\r\n\r\n### 0.5.13 (2021-10-27)\r\n* Update link for Tabnine\r\n\r\n### 0.5.12 (2021-07-31)\r\n* Support Workspace Trust and Virtual Workspaces\r\n\r\n### 0.5.11 (2021-07-09)\r\n* Support self-closing tags with space\r\n\r\n### 0.5.10 (2021-01-06)\r\n* Add sponsor for Tabnine\r\n\r\n### 0.5.9 (2020-10-11)\r\n* [#106](https://github.com/formulahendry/vscode-auto-close-tag/pull/106): Support for auto closing tags starting with underscore\r\n\r\n### 0.5.8 (2020-07-03)\r\n* [#175](https://github.com/formulahendry/vscode-auto-close-tag/pull/175): Add new setting 'Added disableOnLanguage'\r\n\r\n### 0.5.7 (2020-04-21)\r\n* Update support for embedded elixir\r\n* Add support for Apple's property list type (plist)\r\n\r\n### 0.5.6 (2018-02-17)\r\n* Add support for embedded elixir\r\n\r\n### 0.5.5 (2017-12-03)\r\n* Handle void tags that are written in other case than lowercase (HTML tag names are case-insensitive)\r\n\r\n### 0.5.4 (2017-11-30)\r\n* Add support for CFML\r\n\r\n### 0.5.3 (2017-11-04)\r\n* Add support for Multi Root Workspace\r\n\r\n### 0.5.2 (2017-10-22)\r\n* [#65](https://github.com/formulahendry/vscode-auto-close-tag/issues/65): Enable Auto Close Tag on erb file\r\n\r\n### 0.5.1 (2017-09-29)\r\n* [#63](https://github.com/formulahendry/vscode-auto-close-tag/issues/63): Handle space before closing parentheses\r\n\r\n### 0.5.0 (2017-09-08)\r\n* Not enabled for HTML, Handlebars and Razor files, since VS Code has built-in support from v1.16\r\n\r\n### 0.4.3 (2017-06-30)\r\n* [#49](https://github.com/formulahendry/vscode-auto-close-tag/issues/49)\r\n\r\n### 0.4.2 (2017-05-22)\r\n* [#46](https://github.com/formulahendry/vscode-auto-close-tag/issues/46): Enable Auto Close Tag on Liquid\r\n\r\n### 0.4.1 (2017-05-14)\r\n* Enable Auto Close Tag on more template engines\r\n\r\n### 0.4.0 (2017-05-12)\r\n* [#26](https://github.com/formulahendry/vscode-auto-close-tag/issues/26): Enable Auto Close Tag only on a set of languages\r\n\r\n### 0.3.12 (2017-05-02)\r\n* Remove 'Keymaps' category per VS Code team's suggestion\r\n\r\n### 0.3.11 (2017-04-16)\r\n* Resolve [GitHub issue#33](https://github.com/formulahendry/vscode-auto-close-tag/issues/33): Add config entry to enable both Visual Studio and Sublime Text mode\r\n\r\n### 0.3.10 (2017-03-10)\r\n* Resolve [GitHub issue#30](https://github.com/formulahendry/vscode-auto-close-tag/issues/30): Should not close tag inside template literals\r\n\r\n### 0.3.9\r\n* Update key binding to align with Sublime Text\r\n* Resolve [GitHub issue#23](https://github.com/formulahendry/vscode-auto-close-tag/issues/23): Tag should not be auto closed inside quotes\r\n\r\n### 0.3.8\r\n* Resolve [GitHub issue#20](https://github.com/formulahendry/vscode-auto-close-tag/issues/20): Fix automatic close tag after tab switch\r\n\r\n### 0.3.7\r\n* Resolve [GitHub issue#19](https://github.com/formulahendry/vscode-auto-close-tag/issues/19): Fix Auto Close Tag not working in HTML/XML file due to VS Code 1.8 breaking changes\r\n\r\n### 0.3.6\r\n* Resolve [GitHub issue#18](https://github.com/formulahendry/vscode-auto-close-tag/issues/18): Support `.` (dot) in tags\r\n\r\n### 0.3.5\r\n* Merge [PR #15](https://github.com/formulahendry/vscode-auto-close-tag/pull/15)\r\n  * Avoid closing brackets duplication\r\n  * Support `:-_` in tags\r\n\r\n### 0.3.4\r\n* Resolve [GitHub issue#12](https://github.com/formulahendry/vscode-auto-close-tag/issues/12): Path symbol \"/\" problem\r\n\r\n### 0.3.3\r\n* Merge [PR#11](https://github.com/formulahendry/vscode-auto-close-tag/pull/11): Remove left over console.log command\r\n\r\n### 0.3.2\r\n* Resolve [GitHub issue#10](https://github.com/formulahendry/vscode-auto-close-tag/issues/10): add support to close self-closing tag automatically in Sublime Text 3 mode\r\n\r\n### 0.3.1\r\n* Add support to close self-closing tag automatically\r\n\r\n### 0.3.0\r\n* Use Keyboard Shortcut or Command Palette to add close tag manually\r\n* Add config entry to turn on/off auto close tag\r\n\r\n### 0.2.0\r\n* Add config entry to support auto close tag of Sublime Text 3 Mode\r\n\r\n### 0.1.4\r\n* Resolve [GitHub issue#5](https://github.com/formulahendry/vscode-auto-close-tag/issues/5): arrow function shouldn't trigger auto-close\r\n\r\n### 0.1.3\r\n* Resolve [GitHub issue#4](https://github.com/formulahendry/vscode-auto-close-tag/issues/4): providie a config entry to set the tag list that would not be auto closed\r\n\r\n### 0.1.2\r\n* Update README.md to clarify the configuration for `auto-close-tag.activationOnLanguage`\r\n\r\n### 0.1.1\r\n* Match correct opening tag in some corner cases\r\n\r\n### 0.1.0\r\n* Bug fixes\r\n* Add blog info \r\n\r\n### 0.0.3\r\n* Update README.md\r\n\r\n### 0.0.2\r\n* Add configuration to set the languages that the extension will be activated\r\n* Add support for tag with attribute. e.g. `<a href=\"https://www.microsoft.com\"></a>`. So `</a>` will be automatically added.\r\n* Minor bug fix\r\n\r\n### 0.0.1\r\n* Initial Release"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2018 Jun Han\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Auto Close Tag\n\n[![CI](https://github.com/formulahendry/vscode-auto-close-tag/actions/workflows/main.yml/badge.svg)](https://github.com/formulahendry/vscode-auto-close-tag/actions/workflows/main.yml)\n\nAutomatically add HTML/XML close tag, same as Visual Studio IDE or Sublime Text does.\n\n## Book for VS Code\n\n[《Visual Studio Code 权威指南》](https://union-click.jd.com/jdc?e=jdext-1261348777639735296-0&p=AyIGZRhbHQsWAVIaXxEyEgRdG1sRBxU3EUQDS10iXhBeGlcJDBkNXg9JHUlSSkkFSRwSBF0bWxEHFRgMXgdIMkRxFAUJD1RQZT0cBnwKDE4%2BaDpgB2ILWStbHAIQD1QaWxIBIgdUGlsRBxEEUxprJQIXNwd1g6O0yqLkB4%2B%2FjcePwitaJQIWD1cfWhwKGwVSG1wlAhoDZc31gdeauIyr%2FsOovNLYq46cqca50ytrJQEiXABPElAeEgRSG1kQCxQBUxxZHQQQA1YTXAkDIgdUGlscChECXRs1FGwSD1UbWRALFwRWK1slASJZOxoLRlUXU1NONU9QEkdXWRlJbBUDVB9TFgAVN1caWhcA)：带你深入浅出 VS Code！\n\n![Book](images/book.jpg)\n\n## Note\n\nFrom VS Code 1.16, it has [built-in close tag support](https://code.visualstudio.com/updates/v1_16#_html-close-tags) for HTML, Handlebars and Razor files. This extension is enabled for other languages like XML, PHP, Vue, JavaScript, TypeScript, JSX, TSX, GJS, GTS, and so on. It is configurable.\n\n## Features\n\n* Automatically add closing tag when you type in the closing bracket of the opening tag\n* After closing tag is inserted, the cursor is between the opening and closing tag\n* Set the tag list that would not be auto closed\n* Automatically close self-closing tag\n* Support auto close tag as Sublime Text 3\n* Use Keyboard Shortcut or Command Palette to add close tag manually\n\n## Usages\n\nAfter typing in the closing bracket of the opening tag, the closing tag will be inserted automatically.\n\n![Usage](images/usage.gif)\n\nTo add close tag manually, use shortcut `Alt+.` (`Command+Alt+.` for Mac), or press `F1` and then select/type `Close Tag`\n\n![Usage](images/close-tag.gif)\n\n## Sublime Text 3 Mode\n\nTo automatically add close tag when `</` is typed (same as Sublime Text 3 does), set the below config as `true`:\n```json\n{\n    \"auto-close-tag.SublimeText3Mode\": true\n}\n```\nThe setting is `false` by default.\n\n![Sublime Text 3](images/st3.gif)\n\n## Configuration\n\nUse `auto-close-tag.enableAutoCloseTag` to set whether to insert close tag automatically (it is `true` by default):\n```json\n{\n    \"auto-close-tag.enableAutoCloseTag\": true\n}\n```\n\nTo set whether to close self-closing tag automatically (e.g. type `<br`, then type `/`, `>` will be added automatically) (it is `true` by default):\n```json\n{\n    \"auto-close-tag.enableAutoCloseSelfClosingTag\": true\n}\n```\n\nWhether to insert a space before the forward slash in a self-closing tag (it is `false` by default):\n```json\n{\n    \"auto-close-tag.insertSpaceBeforeSelfClosingTag\": false\n}\n```\n\nAdd entry into `auto-close-tag.activationOnLanguage` to set the languages that the extension will be activated. Use `[\"*\"]` to activate for all languages. Below are the default settings:\n```json\n{\n    \"auto-close-tag.activationOnLanguage\": [\n        \"xml\",\n        \"php\",\n        \"blade\",\n        \"ejs\",\n        \"glimmer-js\",\n        \"glimmer-ts\",\n        \"jinja\",\n        \"javascript\",\n        \"javascriptreact\",\n        \"typescript\",\n        \"typescriptreact\",\n        \"plaintext\",\n        \"markdown\",\n        \"vue\",\n        \"liquid\",\n        \"erb\",\n        \"lang-cfml\",\n        \"cfml\",\n        \"HTML (Eex)\"\n    ]\n}\n```\n**Note:** The setting should be set with language id defined in [VS Code](https://github.com/Microsoft/vscode/tree/master/extensions). Taking [javascript definition](https://github.com/Microsoft/vscode/blob/master/extensions/javascript/package.json) as an example, we need to use `javascript` for `.js` and `.es6`, use `javascriptreact` for `.jsx`. So, if you want to enable this extension on `.js` file, you need to add `javascript` in settings.json.\n\nAlternatively you could also exlude the languages where you don't want the extension to be activated. Below is an example:\n```json\n{\n    \"auto-close-tag.disableOnLanguage\": [\n        \"php\",\n        \"python\"\n    ]\n}\n```\n\nYou could also set the tag list that would not be auto closed. Below are the default settings for void elements in HTML per [W3C spec](https://www.w3.org/TR/html-markup/syntax.html#syntax-elements), and you could overwrite it:\n```json\n{\n    \"auto-close-tag.excludedTags\": [\n        \"area\",\n        \"base\",\n        \"br\",\n        \"col\",\n        \"command\",\n        \"embed\",\n        \"hr\",\n        \"img\",\n        \"input\",\n        \"keygen\",\n        \"link\",\n        \"meta\",\n        \"param\",\n        \"source\",\n        \"track\",\n        \"wbr\"\n    ]\n}\n```\n\n`auto-close-tag.fullMode`: Whether to enable both Visual Studio and Sublime Text mode. (Default is **false**)\n\n## Change Log\nSee Change Log [here](CHANGELOG.md)\n\n## Issues\nSubmit the [issues](https://github.com/formulahendry/vscode-auto-close-tag/issues) if you find any bug or have any suggestion.\n\n## Contribution\nFork the [repo](https://github.com/formulahendry/vscode-auto-close-tag) and submit pull requests.\n\n## Blog\nVisit the [blog](https://blogs.msdn.microsoft.com/formulahendry) or the [post](https://blogs.msdn.microsoft.com/formulahendry/2016/06/29/auto-close-tag-for-visual-studio-code/) for more detailed info "
  },
  {
    "path": "package.json",
    "content": "{\n    \"name\": \"auto-close-tag\",\n    \"displayName\": \"Auto Close Tag\",\n    \"description\": \"Automatically add HTML/XML close tag, same as Visual Studio IDE or Sublime Text\",\n    \"version\": \"0.5.15\",\n    \"publisher\": \"formulahendry\",\n    \"icon\": \"images/logo.png\",\n    \"engines\": {\n        \"vscode\": \"^1.49.0\"\n    },\n    \"categories\": [\n        \"Other\",\n        \"Programming Languages\"\n    ],\n    \"keywords\": [\n        \"AutoComplete\",\n        \"close\",\n        \"tag\",\n        \"html\",\n        \"xml\",\n        \"multi-root ready\"\n    ],\n    \"bugs\": {\n        \"url\": \"https://github.com/formulahendry/vscode-auto-close-tag/issues\",\n        \"email\": \"formulahendry@gmail.com\"\n    },\n    \"homepage\": \"https://github.com/formulahendry/vscode-auto-close-tag/blob/master/README.md\",\n    \"repository\": {\n        \"type\": \"git\",\n        \"url\": \"https://github.com/formulahendry/vscode-auto-close-tag.git\"\n    },\n    \"extensionKind\": [\n        \"ui\",\n        \"workspace\"\n    ],\n    \"activationEvents\": [\n        \"*\",\n        \"onCommand:auto-close-tag.closeTag\"\n    ],\n    \"main\": \"./out/src/extension\",\n    \"capabilities\": {\n        \"untrustedWorkspaces\": {\n            \"supported\": true\n        },\n        \"virtualWorkspaces\": true\n    },\n    \"contributes\": {\n        \"commands\": [\n            {\n                \"command\": \"auto-close-tag.closeTag\",\n                \"title\": \"Close Tag\"\n            }\n        ],\n        \"keybindings\": [\n            {\n                \"command\": \"auto-close-tag.closeTag\",\n                \"key\": \"alt+.\",\n                \"mac\": \"cmd+alt+.\"\n            }\n        ],\n        \"configuration\": {\n            \"type\": \"object\",\n            \"title\": \"Auto Close Tag configuration\",\n            \"properties\": {\n                \"auto-close-tag.activationOnLanguage\": {\n                    \"type\": \"array\",\n                    \"default\": [\n                        \"xml\",\n                        \"php\",\n                        \"blade\",\n                        \"ejs\",\n                        \"glimmer-js\",\n                        \"glimmer-ts\",\n                        \"jinja\",\n                        \"javascript\",\n                        \"javascriptreact\",\n                        \"typescript\",\n                        \"typescriptreact\",\n                        \"plaintext\",\n                        \"markdown\",\n                        \"vue\",\n                        \"liquid\",\n                        \"erb\",\n                        \"lang-cfml\",\n                        \"cfml\",\n                        \"HTML (EEx)\",\n                        \"HTML (Eex)\",\n                        \"plist\"\n                    ],\n                    \"description\": \"Set the languages that the extension will be activated.  e.g. [\\\"html\\\",\\\"xml\\\",\\\"php\\\"]. Use [\\\"*\\\"] to activate for all languages.\",\n                    \"scope\": \"resource\"\n                },\n                \"auto-close-tag.disableOnLanguage\": {\n                    \"type\": \"array\",\n                    \"default\": [],\n                    \"description\": \"Set the languages where the extension will be disabled.  e.g. [\\\"html\\\",\\\"xml\\\",\\\"php\\\"].\",\n                    \"scope\": \"resource\"\n                },\n                \"auto-close-tag.excludedTags\": {\n                    \"type\": \"array\",\n                    \"default\": [\n                        \"area\",\n                        \"base\",\n                        \"br\",\n                        \"col\",\n                        \"command\",\n                        \"embed\",\n                        \"hr\",\n                        \"img\",\n                        \"input\",\n                        \"keygen\",\n                        \"link\",\n                        \"meta\",\n                        \"param\",\n                        \"source\",\n                        \"track\",\n                        \"wbr\"\n                    ],\n                    \"description\": \"Set the tag list that would not be auto closed.\",\n                    \"scope\": \"resource\"\n                },\n                \"auto-close-tag.SublimeText3Mode\": {\n                    \"type\": \"boolean\",\n                    \"default\": false,\n                    \"description\": \"Auto close tag when </ is typed, same as Sublime Text 3\",\n                    \"scope\": \"resource\"\n                },\n                \"auto-close-tag.enableAutoCloseTag\": {\n                    \"type\": \"boolean\",\n                    \"default\": true,\n                    \"description\": \"Whether to insert close tag automatically\",\n                    \"scope\": \"resource\"\n                },\n                \"auto-close-tag.enableAutoCloseSelfClosingTag\": {\n                    \"type\": \"boolean\",\n                    \"default\": true,\n                    \"description\": \"Whether to close self-closing tag automatically\",\n                    \"scope\": \"resource\"\n                },\n                \"auto-close-tag.insertSpaceBeforeSelfClosingTag\": {\n                    \"type\": \"boolean\",\n                    \"default\": false,\n                    \"description\": \"Insert a space before the forward slash in a self-closing tag.\",\n                    \"scope\": \"resource\"\n                },\n                \"auto-close-tag.fullMode\": {\n                    \"type\": \"boolean\",\n                    \"default\": false,\n                    \"description\": \"Enable both Visual Studio and Sublime Text mode\",\n                    \"scope\": \"resource\"\n                }\n            }\n        }\n    },\n    \"scripts\": {\n        \"vscode:prepublish\": \"tsc -p ./\",\n        \"compile\": \"tsc -watch -p ./\"\n    },\n    \"devDependencies\": {\n        \"@types/mocha\": \"^2.2.32\",\n        \"@types/node\": \"^6.0.40\",\n        \"@types/vscode\": \"^1.49.0\",\n        \"mocha\": \"^2.3.3\",\n        \"typescript\": \"^3.9.10\"\n    }\n}\n"
  },
  {
    "path": "src/extension.ts",
    "content": "'use strict';\nimport * as vscode from 'vscode';\n\nexport function activate(context: vscode.ExtensionContext) {\n    vscode.workspace.onDidChangeTextDocument(event => {\n        insertAutoCloseTag(event);\n    });\n\n    let closeTag = vscode.commands.registerCommand('auto-close-tag.closeTag', () => {\n        insertCloseTag();\n    });\n\n    context.subscriptions.push(closeTag);\n}\n\n// this method is called when your extension is deactivated\nexport function deactivate() {\n}\n\nfunction insertAutoCloseTag(event: vscode.TextDocumentChangeEvent): void {\n    if (!event.contentChanges[0] || ( event.reason && event.reason == vscode.TextDocumentChangeReason.Undo ) || ( event.reason && event.reason == vscode.TextDocumentChangeReason.Redo ) ) {\n        return;\n    }\n    let isRightAngleBracket = CheckRightAngleBracket(event.contentChanges[0]);\n    if (!isRightAngleBracket && event.contentChanges[0].text !== \"/\") {\n        return;\n    }\n\n    let editor = vscode.window.activeTextEditor;\n    if (!editor || ( editor && event.document !== editor.document ) ) {\n        return;\n    }\n\n    let config = vscode.workspace.getConfiguration('auto-close-tag', editor.document.uri);\n    if (!config.get<boolean>(\"enableAutoCloseTag\", true)) {\n        return;\n    }\n\n    let languageId = editor.document.languageId;\n    let languages = config.get<string[]>(\"activationOnLanguage\", [\"*\"]);\n    let disableOnLanguage = config.get<string[]>(\"disableOnLanguage\", []);\n    if ((languages.indexOf(\"*\") === -1 && languages.indexOf(languageId) === -1) || disableOnLanguage.indexOf(languageId) !== -1) {\n        return;\n    }\n\n    let selection = editor.selection;\n    let originalPosition = selection.start.translate(0, 1);\n    let excludedTags = config.get<string[]>(\"excludedTags\", []);\n    let isSublimeText3Mode = config.get<boolean>(\"SublimeText3Mode\", false);\n    let enableAutoCloseSelfClosingTag = config.get<boolean>(\"enableAutoCloseSelfClosingTag\", true);\n    let isFullMode = config.get<boolean>(\"fullMode\");\n\n    if ((isSublimeText3Mode || isFullMode) && event.contentChanges[0].text === \"/\") {\n        let text = editor.document.getText(new vscode.Range(new vscode.Position(0, 0), originalPosition));\n        let last2chars = \"\";\n        if (text.length > 2) {\n            last2chars = text.substr(text.length - 2);\n        }\n        if (last2chars === \"</\") {\n            let closeTag = getCloseTag(text, excludedTags);\n            if (closeTag) {\n                let nextChar = getNextChar(editor, originalPosition);\n                if (nextChar === \">\") {\n                    closeTag = closeTag.substr(0, closeTag.length - 1);\n                }\n                editor.edit((editBuilder) => {\n                    editBuilder.insert(originalPosition, closeTag);\n                }).then(() => {\n                    if (nextChar === \">\") {\n                        editor.selection = moveSelectionRight(editor.selection, 1);\n                    }\n                });\n            }\n        }\n    }\n\n    if (((!isSublimeText3Mode || isFullMode) && isRightAngleBracket) ||\n        (enableAutoCloseSelfClosingTag && event.contentChanges[0].text === \"/\")) {\n        let textLine = editor.document.lineAt(selection.start);\n        let text = textLine.text.substring(0, selection.start.character + 1);\n        let result = /<([_a-zA-Z][a-zA-Z0-9:\\-_.]*)(?:\\s+[^<>]*?[^\\s/<>=]+?)*?\\s?(\\/|>)$/.exec(text);\n        if (result !== null && ((occurrenceCount(result[0], \"'\") % 2 === 0)\n            && (occurrenceCount(result[0], \"\\\"\") % 2 === 0) && (occurrenceCount(result[0], \"`\") % 2 === 0))) {\n            if (result[2] === \">\") {\n                if (excludedTags.indexOf(result[1].toLowerCase()) === -1) {\n                    editor.edit((editBuilder) => {\n                        editBuilder.insert(originalPosition, \"</\" + result[1] + \">\");\n                    }).then(() => {\n                        editor.selection = new vscode.Selection(originalPosition, originalPosition);\n                    });\n                }\n            } else {\n                if (textLine.text.length <= selection.start.character + 1 || textLine.text[selection.start.character + 1] !== '>') { // if not typing \"/\" just before \">\", add the \">\" after \"/\"\n                    editor.edit((editBuilder) => {\n                        if (config.get<boolean>(\"insertSpaceBeforeSelfClosingTag\")) {\n                            const spacePosition = originalPosition.translate(0, -1);\n                            editBuilder.insert(spacePosition, \" \");\n                        }\n                        editBuilder.insert(originalPosition, \">\");\n                    })\n                }\n            }\n        }\n    }\n}\n\nfunction CheckRightAngleBracket(contentChange: vscode.TextDocumentContentChangeEvent): boolean {\n    return contentChange.text === \">\" || CheckRightAngleBracketInVSCode_1_8(contentChange);\n}\n\nfunction CheckRightAngleBracketInVSCode_1_8(contentChange: vscode.TextDocumentContentChangeEvent): boolean {\n    return contentChange.text.endsWith(\">\") && contentChange.range.start.character === 0\n        && contentChange.range.start.line === contentChange.range.end.line\n        && !contentChange.range.end.isEqual(new vscode.Position(0, 0));\n}\n\nfunction insertCloseTag(): void {\n    let editor = vscode.window.activeTextEditor;\n    if (!editor) {\n        return;\n    }\n\n    let selection = editor.selection;\n    let originalPosition = selection.start;\n    let config = vscode.workspace.getConfiguration('auto-close-tag', editor.document.uri);\n    let excludedTags = config.get<string[]>(\"excludedTags\", []);\n    let text = editor.document.getText(new vscode.Range(new vscode.Position(0, 0), originalPosition));\n    if (text.length > 2) {\n        let closeTag = getCloseTag(text, excludedTags);\n        if (closeTag) {\n            editor.edit((editBuilder) => {\n                editBuilder.insert(originalPosition, closeTag);\n            });\n        }\n    }\n}\n\nfunction getNextChar(editor: vscode.TextEditor, position: vscode.Position): string {\n    let nextPosition = position.translate(0, 1);\n    let text = editor.document.getText(new vscode.Range(position, nextPosition));\n    return text;\n}\n\nfunction getCloseTag(text: string, excludedTags: string[]): string {\n    let regex = /<(\\/?[_a-zA-Z][a-zA-Z0-9:\\-_.]*)(?:\\s+[^<>]*?[^\\s/<>=]+?)*?\\s?>/g;\n    let result = null;\n    let stack = [];\n    while ((result = regex.exec(text)) !== null) {\n        let isStartTag = result[1].substr(0, 1) !== \"/\";\n        let tag = isStartTag ? result[1] : result[1].substr(1);\n        if (excludedTags.indexOf(tag.toLowerCase()) === -1) {\n            if (isStartTag) {\n                stack.push(tag);\n            } else if (stack.length > 0) {\n                let lastTag = stack[stack.length - 1];\n                if (lastTag === tag) {\n                    stack.pop()\n                }\n            }\n        }\n    }\n    if (stack.length > 0) {\n        let closeTag = stack[stack.length - 1];\n        if (text.substr(text.length - 2) === \"</\") {\n            return closeTag + \">\";\n        }\n        if (text.substr(text.length - 1) === \"<\") {\n            return \"/\" + closeTag + \">\";\n        }\n        return \"</\" + closeTag + \">\";\n    } else {\n        return null;\n    }\n}\n\nfunction moveSelectionRight(selection: vscode.Selection, shift: number): vscode.Selection {\n    let newPosition = selection.active.translate(0, shift);\n    let newSelection = new vscode.Selection(newPosition, newPosition);\n    return newSelection;\n}\n\nfunction occurrenceCount(source: string, find: string): number {\n    return source.split(find).length - 1;\n}\n"
  },
  {
    "path": "test/extension.test.ts",
    "content": "//\n// Note: This example test is leveraging the Mocha test framework.\n// Please refer to their documentation on https://mochajs.org/ for help.\n//\n\n// The module 'assert' provides assertion methods from node\nimport * as assert from 'assert';\n\n// You can import and use all API from the 'vscode' module\n// as well as import your extension to test it\nimport * as vscode from 'vscode';\nimport * as myExtension from '../src/extension';\n\n// Defines a Mocha test suite to group tests of similar kind together\nsuite(\"Extension Tests\", () => {\n\n    // Defines a Mocha unit test\n    test(\"Something 1\", () => {\n        assert.equal(-1, [1, 2, 3].indexOf(5));\n        assert.equal(-1, [1, 2, 3].indexOf(0));\n    });\n});"
  },
  {
    "path": "test/index.ts",
    "content": "//\n// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING\n//\n// This file is providing the test runner to use when running extension tests.\n// By default the test runner in use is Mocha based.\n//\n// You can provide your own test runner if you want to override it by exporting\n// a function run(testRoot: string, clb: (error:Error) => void) that the extension\n// host can call to run the tests. The test runner is expected to use console.log\n// to report the results back to the caller. When the tests are finished, return\n// a possible error to the callback or null if none.\n\nvar testRunner = require('vscode/lib/testrunner');\n\n// You can directly control Mocha options by uncommenting the following lines\n// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info\ntestRunner.configure({\n    ui: 'tdd', \t\t// the TDD UI is being used in extension.test.ts (suite, test, etc.)\n    useColors: true // colored output from test results\n});\n\nmodule.exports = testRunner;"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n    \"compilerOptions\": {\n        \"module\": \"commonjs\",\n        \"target\": \"es6\",\n        \"outDir\": \"out\",\n        \"lib\": [\n            \"es6\"\n        ],\n        \"sourceMap\": true,\n        \"rootDir\": \".\"\n    },\n    \"exclude\": [\n        \"node_modules\",\n        \".vscode-test\"\n    ]\n}"
  }
]