Skip to content

Commit

Permalink
fix(language-server): fix issue with survey prompt
Browse files Browse the repository at this point in the history
Caused by native compilation as explained here: dotnet/corert#5467
  • Loading branch information
chrissimon-au committed Oct 14, 2023
1 parent 94669b2 commit 7196e82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ let showMessageRequestHandlerBuilder: HandlerBuilder<ShowMessageRequestParams, M
let showDocumentRequestHandlerBuilder: HandlerBuilder<ShowDocumentParams, ShowDocumentResult> =
handlerBuilder "window/showDocument"

let latchFile = Path.Combine(System.AppContext.BaseDirectory, "survey-prompted.txt")

[<Tests>]
let initializationTests =
testSequenced
Expand All @@ -39,9 +41,6 @@ let initializationTests =
[ testAsync "Server shows survey prompt and creates latch file, if latch-file doesn't exit" {
let messageAwaiter = ConditionAwaiter.create ()

let latchFile =
Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "survey-prompted.txt")

File.Delete(latchFile)

let pathValue = Guid.NewGuid().ToString()
Expand Down Expand Up @@ -69,9 +68,6 @@ let initializationTests =
testAsync "Server does not show prompt if latch-file already exists" {
let messageAwaiter = ConditionAwaiter.create ()

let latchFile =
Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "survey-prompted.txt")

File.Create(latchFile).Close()

let pathValue = Guid.NewGuid().ToString()
Expand All @@ -95,9 +91,6 @@ let initializationTests =
let messageAwaiter = ConditionAwaiter.create ()
let showDocAwaiter = ConditionAwaiter.create ()

let latchFile =
Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "survey-prompted.txt")

File.Delete(latchFile)

let pathValue = Guid.NewGuid().ToString()
Expand Down
16 changes: 10 additions & 6 deletions src/language-server/Contextive.LanguageServer/Server.fs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ let private getWorkspaceFolder (s: ILanguageServer) =
else
None

let showSurveyPrompt (s: ILanguageServer) =
let private showSurveyPrompt (s: ILanguageServer) =
task {
let latchFile =
Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "survey-prompted.txt")
Path.Combine(System.AppContext.BaseDirectory, "survey-prompted.txt")

if not <| File.Exists(latchFile) then
File.Create(latchFile).Close()
Expand Down Expand Up @@ -87,10 +87,13 @@ let showSurveyPrompt (s: ILanguageServer) =

}

let private onStartup definitions =
OnLanguageServerStartedDelegate(fun (s: ILanguageServer) _cancellationToken ->
showSurveyPrompt (s) |> ignore
let private onStartupShowSurveyPrompt =
OnLanguageServerStartedDelegate(fun (s: ILanguageServer) _cancellationToken ->
showSurveyPrompt (s)
)

let private onStartupConfigureServer definitions =
OnLanguageServerStartedDelegate(fun (s: ILanguageServer) _cancellationToken ->
async {
s.Window.LogInfo $"Starting {name} v{version}..."
let configGetter () = getConfig s configSection pathKey
Expand Down Expand Up @@ -130,7 +133,8 @@ let private configureServer (input: Stream) (output: Stream) (opts: LanguageServ
.WithInput(input)
.WithOutput(output)

.OnStarted(onStartup definitions)
.OnStarted(onStartupConfigureServer definitions)
.OnStarted(onStartupShowSurveyPrompt)
.WithConfigurationSection(configSection) // Add back in when implementing didConfigurationChanged handling
.ConfigureLogging(fun z ->
z
Expand Down

0 comments on commit 7196e82

Please sign in to comment.