@@ -20,19 +20,19 @@ struct CopilotView: View {
2020 @AppStorage ( \. gitHubCopilotUseStrictSSL) var gitHubCopilotUseStrictSSL
2121 @AppStorage ( \. gitHubCopilotIgnoreTrailingNewLines)
2222 var gitHubCopilotIgnoreTrailingNewLines
23+ @AppStorage ( \. disableGitHubCopilotSettingsAutoRefreshOnAppear)
24+ var disableGitHubCopilotSettingsAutoRefreshOnAppear
2325 init ( ) { }
2426 }
2527
2628 class ViewModel : ObservableObject {
2729 let installationManager = GitHubCopilotInstallationManager ( )
2830
29- @Published var installationStatus : GitHubCopilotInstallationManager . InstallationStatus
31+ @Published var installationStatus : GitHubCopilotInstallationManager . InstallationStatus ?
3032 @Published var installationStep : GitHubCopilotInstallationManager . InstallationStep ?
3133
32- init ( ) {
33- installationStatus = installationManager. checkInstallation ( )
34- }
35-
34+ init ( ) { }
35+
3636 init (
3737 installationStatus: GitHubCopilotInstallationManager . InstallationStatus ,
3838 installationStep: GitHubCopilotInstallationManager . InstallationStep ?
@@ -172,6 +172,8 @@ struct CopilotView: View {
172172 VStack ( alignment: . leading) {
173173 HStack {
174174 switch viewModel. installationStatus {
175+ case . none:
176+ Text ( " Copilot.Vim Version: Loading.. " )
175177 case . notInstalled:
176178 Text ( " Copilot.Vim Version: Not Installed " )
177179 installButton
@@ -194,7 +196,10 @@ struct CopilotView: View {
194196 Text ( " Status: \( status? . description ?? " Loading.. " ) " )
195197
196198 HStack ( alignment: . center) {
197- Button ( " Refresh " ) { checkStatus ( ) }
199+ Button ( " Refresh " ) {
200+ viewModel. refreshInstallationStatus ( )
201+ checkStatus ( )
202+ }
198203 if status == . notSignedIn {
199204 Button ( " Sign In " ) { signIn ( ) }
200205 . alert ( isPresented: $isUserCodeCopiedAlertPresented) {
@@ -261,6 +266,8 @@ struct CopilotView: View {
261266 Spacer ( )
262267 } . onAppear {
263268 if isPreview { return }
269+ if settings. disableGitHubCopilotSettingsAutoRefreshOnAppear { return }
270+ viewModel. refreshInstallationStatus ( )
264271 checkStatus ( )
265272 } . onChange ( of: settings. runNodeWith) { _ in
266273 Self . copilotAuthService = nil
0 commit comments