mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-31 01:00:29 -04:00
SQL Operations Studio Public Preview 1 (0.23) release source code
This commit is contained in:
37
src/vs/editor/contrib/indentation/common/indentUtils.ts
Normal file
37
src/vs/editor/contrib/indentation/common/indentUtils.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export function getSpaceCnt(str, tabSize) {
|
||||
let spacesCnt = 0;
|
||||
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
if (str.charAt(i) === '\t') {
|
||||
spacesCnt += tabSize;
|
||||
} else {
|
||||
spacesCnt++;
|
||||
}
|
||||
}
|
||||
|
||||
return spacesCnt;
|
||||
}
|
||||
|
||||
export function generateIndent(spacesCnt: number, tabSize, insertSpaces) {
|
||||
spacesCnt = spacesCnt < 0 ? 0 : spacesCnt;
|
||||
|
||||
let result = '';
|
||||
if (!insertSpaces) {
|
||||
let tabsCnt = Math.floor(spacesCnt / tabSize);
|
||||
spacesCnt = spacesCnt % tabSize;
|
||||
for (let i = 0; i < tabsCnt; i++) {
|
||||
result += '\t';
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < spacesCnt; i++) {
|
||||
result += ' ';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user