Bug 723459 - Add an API to SourceEditor to retrieve the character(s) used for indentation. r=msucan

This commit is contained in:
Cedric Vivier 2012-02-02 04:18:00 +01:00
parent c33b3c8a7a
commit 4dbf499a75
2 changed files with 17 additions and 0 deletions

View File

@ -809,6 +809,20 @@ SourceEditor.prototype = {
return this._model.getLineDelimiter();
},
/**
* Get the indentation string used in the document being edited.
*
* @return string
* The indentation string.
*/
getIndentationString: function SE_getIndentationString()
{
if (this._expandTab) {
return (new Array(this._tabSize + 1)).join(" ");
}
return "\t";
},
/**
* Set the source editor mode to the file type you are editing.
*

View File

@ -324,6 +324,9 @@ function testReturnKey()
let lineDelimiter = editor.getLineDelimiter();
ok(lineDelimiter, "we have the line delimiter");
let indentationString = editor.getIndentationString();
is(" ", indentationString, "we have an indentation string of 7 spaces");
is(editor.getText(), " a" + lineDelimiter + " x\n b\n c",
"return maintains indentation");