@ -1,11 +1,11 @@
'use strict' ;
import { ExtensionContext , extensions , languages , window , workspace } from 'vscode' ;
import { AnnotationController } from './annotations/annotationController' ;
import { CodeLensLocations , Co nfiguration , IConfig , LineHighlightLocations } from './configuration' ;
import { Configuration , IConfig } from './configuration' ;
import { ApplicationInsightsKey , CommandContext , ExtensionKey , GlobalState , QualifiedExtensionId , setCommandContext } from './constants' ;
import { CodeLensController } from './codeLensController' ;
import { configureCommands } from './commands' ;
import { CurrentLineController , LineAnnotationType } from './currentLineController' ;
import { CurrentLineController } from './currentLineController' ;
import { GitContentProvider } from './gitContentProvider' ;
import { GitExplorer } from './views/gitExplorer' ;
import { GitRevisionCodeLensProvider } from './gitRevisionCodeLensProvider' ;
@ -49,7 +49,6 @@ export async function activate(context: ExtensionContext) {
telemetryContext [ 'git.version' ] = gitVersion ;
Telemetry . setContext ( telemetryContext ) ;
await migrateSettings ( context ) ;
notifyOnUnsupportedGitVersion ( context , gitVersion ) ;
notifyOnNewGitLensVersion ( context , gitlensVersion ) ;
@ -88,127 +87,6 @@ export async function activate(context: ExtensionContext) {
// this method is called when your extension is deactivated
export function deactivate() { }
async function migrateSettings ( context : ExtensionContext ) {
const previousVersion = context . globalState . get < string > ( GlobalState . GitLensVersion ) ;
if ( previousVersion === undefined ) return ;
const [ major ] = previousVersion . split ( '.' ) ;
if ( parseInt ( major , 10 ) >= 4 ) return ;
try {
const cfg = workspace . getConfiguration ( ExtensionKey ) ;
const prevCfg = workspace . getConfiguration ( ) . get < any > ( ExtensionKey ) ! ;
if ( prevCfg . blame !== undefined && prevCfg . blame . annotation !== undefined ) {
switch ( prevCfg . blame . annotation . activeLine ) {
case 'off' :
await cfg . update ( 'blame.line.enabled' , false , true ) ;
break ;
case 'hover' :
await cfg . update ( 'blame.line.annotationType' , LineAnnotationType . Hover , true ) ;
break ;
}
if ( prevCfg . blame . annotation . activeLineDarkColor != null ) {
await cfg . update ( 'theme.annotations.line.trailing.dark.foregroundColor' , prevCfg . blame . annotation . activeLineDarkColor , true ) ;
}
if ( prevCfg . blame . annotation . activeLineLightColor != null ) {
await cfg . update ( 'theme.annotations.line.trailing.light.foregroundColor' , prevCfg . blame . annotation . activeLineLightColor , true ) ;
}
switch ( prevCfg . blame . annotation . highlight ) {
case 'none' :
await cfg . update ( 'blame.file.lineHighlight.enabled' , false ) ;
break ;
case 'gutter' :
await cfg . update ( 'blame.file.lineHighlight.locations' , [ LineHighlightLocations . Gutter , LineHighlightLocations . OverviewRuler ] , true ) ;
break ;
case 'line' :
await cfg . update ( 'blame.file.lineHighlight.locations' , [ LineHighlightLocations . Line , LineHighlightLocations . OverviewRuler ] , true ) ;
break ;
case 'both' :
}
if ( prevCfg . blame . annotation . dateFormat != null ) {
await cfg . update ( 'annotations.file.gutter.dateFormat' , prevCfg . blame . annotation . dateFormat , true ) ;
await cfg . update ( 'annotations.line.trailing.dateFormat' , prevCfg . blame . annotation . dateFormat , true ) ;
}
}
if ( prevCfg . codeLens !== undefined ) {
switch ( prevCfg . codeLens . visibility ) {
case 'ondemand' :
case 'off' :
await cfg . update ( 'codeLens.enabled' , false ) ;
}
switch ( prevCfg . codeLens . location ) {
case 'all' :
await cfg . update ( 'codeLens.locations' , [ CodeLensLocations . Document , CodeLensLocations . Containers , CodeLensLocations . Blocks ] , true ) ;
break ;
case 'document+containers' :
await cfg . update ( 'codeLens.locations' , [ CodeLensLocations . Document , CodeLensLocations . Containers ] , true ) ;
break ;
case 'document' :
await cfg . update ( 'codeLens.locations' , [ CodeLensLocations . Document ] , true ) ;
break ;
}
if ( prevCfg . codeLens . locationCustomSymbols != null ) {
await cfg . update ( 'codeLens.customLocationSymbols' , prevCfg . codeLens . locationCustomSymbols , true ) ;
}
}
if ( ( prevCfg . menus && prevCfg . menus . diff && prevCfg . menus . diff . enabled ) === false ) {
await cfg . update ( 'advanced.menus' , {
editorContext : {
blame : true ,
copy : true ,
details : true ,
fileDiff : false ,
history : true ,
lineDiff : false ,
remote : true
} ,
editorTitle : {
blame : true ,
fileDiff : false ,
history : true ,
remote : true ,
status : true
} ,
editorTitleContext : {
blame : true ,
fileDiff : false ,
history : true ,
remote : true
} ,
explorerContext : {
fileDiff : false ,
history : true ,
remote : true
}
} , true ) ;
}
switch ( prevCfg . statusBar && prevCfg . statusBar . date ) {
case 'off' :
await cfg . update ( 'statusBar.format' , '${author}' , true ) ;
break ;
case 'absolute' :
await cfg . update ( 'statusBar.format' , '${author}, ${date}' , true ) ;
break ;
}
}
catch ( ex ) {
Logger . error ( ex , 'migrateSettings' ) ;
}
finally {
window . showInformationMessage ( ` GitLens v4 adds many new settings and removes a few old ones, so please review your settings to ensure they are configured properly. ` ) ;
}
}
async function notifyOnNewGitLensVersion ( context : ExtensionContext , version : string ) {
if ( context . globalState . get ( SuppressedKeys . UpdateNotice , false ) ) return ;