diff --git a/CHANGELOG.md b/CHANGELOG.md index 6387af0..24c9246 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### 1.0.12 (2017-08-02) + +- Add TextEditor.getTabLength() + ### 1.0.11 (2017-08-02) - Update package dependency versions diff --git a/package-lock.json b/package-lock.json index b969791..fd4907a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "qub-vscode", - "version": "1.0.11", + "version": "1.0.12", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c4485a0..6059c19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qub-vscode", - "version": "1.0.11", + "version": "1.0.12", "description": "A collection of common data structures and functions that make creating Visual Studio Code extensions easier.", "files": [ "*.js", diff --git a/sources/interfaces.ts b/sources/interfaces.ts index e7d85e0..80d6332 100644 --- a/sources/interfaces.ts +++ b/sources/interfaces.ts @@ -131,6 +131,11 @@ export interface TextEditor { */ getIndent(): string; + /** + * Get the number of spaces that go into a single tab. + */ + getTabLength(): number; + /** * Get the current newline string used by this editor (\n, \r\n, etc.). */ diff --git a/sources/mocks.ts b/sources/mocks.ts index 9dd3386..444a8e0 100644 --- a/sources/mocks.ts +++ b/sources/mocks.ts @@ -121,7 +121,7 @@ export class TextEditor implements interfaces.TextEditor { this.setCursorIndex(startIndex + qub.getLength(text)); - return + return } public getIndent(): string { @@ -132,6 +132,10 @@ export class TextEditor implements interfaces.TextEditor { this._indent = indent; } + public getTabLength(): number { + return 2; + } + public getNewLine(): string { return this._newline; } diff --git a/sources/vscode.ts b/sources/vscode.ts index 947e0eb..de399b1 100644 --- a/sources/vscode.ts +++ b/sources/vscode.ts @@ -96,6 +96,10 @@ class TextEditor implements interfaces.TextEditor { return this._textEditor.options.insertSpaces ? qub.repeat(" ", this._textEditor.options.tabSize) : "\t"; } + public getTabLength(): number { + return this._textEditor.options.tabSize as number; + } + public getNewLine(): string { return "\n"; } diff --git a/tests/mocks.tests.ts b/tests/mocks.tests.ts index 3f797ef..5c62b6f 100644 --- a/tests/mocks.tests.ts +++ b/tests/mocks.tests.ts @@ -144,6 +144,7 @@ suite("Mocks", () => { assert.deepStrictEqual(editor.getDocument(), undefined); assert.deepStrictEqual(editor.getCursorIndex(), 0); assert.deepStrictEqual(editor.getIndent(), " "); + assert.deepStrictEqual(editor.getTabLength(), 2); assert.deepStrictEqual(editor.getNewLine(), "\n"); }); });