import * as vscode from 'vscode' ; export function config ( section , scope ? ) { return vscode . workspace . getConfiguration ( section , scope ) ; } export function getFolderName ( folder ) { return normalizeFolderName ( folder . uri . toString ( ) ) ; } export function normalizeFolderName ( folderName ) { if ( folderName . charAt ( folderName . length - 1 ) !== '/' ) { folderName = folderName + '/' ; } return folderName ; } export function getWorkspaceFolder ( folderName ) { return vscode . workspace . getWorkspaceFolder ( vscode . Uri . parse ( folderName ) ) ; } export function getActiveTextEditor ( ) { return vscode . window . visibleTextEditors . find ( ( textEditor ) => ! ! textEditor . viewColumn ) ; } export function isTerraformFile ( document ? ) { if ( document === undefined ) { return false ; } if ( document . isUntitled ) { return false ; } if ( document . fileName . endsWith ( 'tf' ) ) { return true ; } return false ; } export function sortedWorkspaceFolders ( ) { const workspaceFolders = vscode . workspace . workspaceFolders ; if ( workspaceFolders ) { return workspaceFolders . map ( ( f ) => getFolderName ( f ) ) . sort ( ( a , b ) => { return a . length - b . length ; } ) ; } return [ ] ; }