Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit07d5abd

Browse files
committed
Use warning dialog that can be suppressed
1 parent3bf5251 commit07d5abd

File tree

3 files changed

+71
-48
lines changed

3 files changed

+71
-48
lines changed

‎vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/VFSIstrings.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ sessionTerminationDetected,"Session termination detected. Press Enter to restart
88
fsharpInteractive,"F# Interactive"
99
couldNotFindFsiExe,"Could not find fsi.exe, the F# Interactive executable.\nThis file does not exist:\n\n%s\n"
1010
killingProcessRaisedException,"Killing process raised exception:\n%s"
11-
sessionIsNotDebugFriendly,"The current F# Interactive session is not configured for debugging. For the best experience, enable debugging in F# Interactive settings, then reset the session.\n\nPress OK to debug with the current settings, or Cancel to abort."
11+
sessionIsNotDebugFriendly,"The current F# Interactive session is not configured for debugging. For the best experience, enable debugging in F# Interactive settings, then reset the session.\n\nAttempt debugging with current settings?"
12+
doNotShowWarningInFuture,"Don't show this warning again"

‎vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiBasis.fs‎

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ open System
2121
openSystem.IO
2222
openSystem.Diagnostics
2323
openSystem.Globalization
24+
openSystem.Text.RegularExpressions
2425
openSystem.Windows.Forms
2526
openSystem.Runtime.InteropServices
2627
openSystem.ComponentModel.Design
@@ -103,7 +104,51 @@ module internal Util =
103104
letthrowOnFailure2(res,a,b)= Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure res|> ignore;(a,b)
104105
letthrowOnFailure3(res,a,b,c)= Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure res|> ignore;(a,b,c)
105106
letthrowOnFailure4(res,a,b,c,d)= Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure res|> ignore;(a,b,c,d)
106-
107+
108+
moduleRegistryHelpers=
109+
/// returns Some(value) if key/value exists, None otherwise
110+
lettryReadHKCU<'t>subkey valueName=
111+
use key= Registry.CurrentUser.OpenSubKey(subkey)
112+
if key=nullthen Noneelse
113+
match key.GetValue(valueName)with
114+
|:? 'tas valTyped-> Some(valTyped)
115+
|_-> None
116+
117+
/// write value to HKCU subkey, uses default .NET/registry type conversions
118+
letwriteHKCU subkey valueName value=
119+
use key= Registry.CurrentUser.OpenSubKey(subkey,true)
120+
key.SetValue(valueName, value)
121+
122+
moduleArgParsing=
123+
letprivatelastIndexOfPattern s patt=
124+
letpatt'= sprintf@"(\s|^)%s(\s|$)" patt
125+
match Regex.Matches(s, patt')|> Seq.cast<Match>|> Seq.tryLastwith
126+
| None->-1
127+
| Some(m)-> m.Index
128+
129+
/// checks if combined arg string results in debug info on/off
130+
letdebugInfoEnabled(args:string)=
131+
// FSI default is --debug:pdbonly, so disabling must be explicit
132+
match lastIndexOfPattern args@"(--|/)debug-"with
133+
|-1->true
134+
| idxDisabled->
135+
// check if it's enabled by later args
136+
letafterDisabled= args.Substring(idxDisabled+5)
137+
letidxEnabled=
138+
[lastIndexOfPattern afterDisabled@"(--|/)debug(\+|:full|:pdbonly)?"
139+
lastIndexOfPattern afterDisabled@"(--|/)g"]|> List.max
140+
idxEnabled> idxDisabled
141+
142+
/// checks if combined arg string results in optimizations on/off
143+
letoptimizationsEnabled(args:string)=
144+
// FSI default is --optimize+, so disabling must be explicit
145+
match lastIndexOfPattern args@"(--|/)optimize-"with
146+
|-1->true
147+
| idxDisabled->
148+
// check if it's enabled by later args
149+
letafterDisabled= args.Substring(idxDisabled+5)
150+
letidxEnabled= lastIndexOfPattern afterDisabled@"(--|/)optimize\+?"
151+
idxEnabled> idxDisabled
107152

108153
// History buffer.
109154
// For now, follows the cmd.exe model.

‎vsintegration/src/vs/FsPkgs/FSharp.VS.FSI/fsiSessionToolWindow.fs‎

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ open System
66
openSystem.Diagnostics
77
openSystem.Globalization
88
openSystem.Runtime.InteropServices
9-
openSystem.Text.RegularExpressions
109
openSystem.ComponentModel.Design
1110
openMicrosoft.Win32
1211
openMicrosoft.VisualStudio
@@ -36,6 +35,10 @@ type internal ITestVFSI =
3635
#nowarn"47"
3736
moduleinternalLocals=
3837
letfsiFontsAndColorsCategory=new Guid("{00CCEE86-3140-4E06-A65A-A92665A40D6F}")
38+
letdefaultVSRegistryRoot=@"Software\Microsoft\VisualStudio\14.0"
39+
letsettingsRegistrySubKey=@"General"
40+
letdebugPromptRegistryValue="FSharpHideScriptDebugWarning"
41+
3942
letfixServerPrompt(str:string)=
4043
// Prompts come through as "SERVER-PROMPT>\n" (when in "server mode").
4144
// In fsi.exe, the newline is needed to get the output send through to VS.
@@ -490,55 +493,29 @@ type internal FsiToolWindow() as this =
490493

491494
// checks if current session is configured such that debugging will work well
492495
// if not, pops a dialog warning the user
493-
letcheckDebuggability()=
494-
letlastIndexOfPattern s patt=
495-
letpatt'= sprintf@"(\s|^)%s(\s|$)" patt
496-
match Regex.Matches(s, patt')|> Seq.cast<Match>|> Seq.tryLastwith
497-
| None->-1
498-
| Some(m)-> m.Index
499-
500-
// checks if combined arg string results in debug info on/off
501-
letdebugInfoEnabled(args:string)=
502-
// FSI default is --debug:pdbonly, so disabling must be explicit
503-
match lastIndexOfPattern args@"(--|/)debug-"with
504-
|-1->true
505-
| idxDisabled->
506-
// check if it's enabled by later args
507-
letafterDisabled= args.Substring(idxDisabled+5)
508-
letidxEnabled=
509-
[lastIndexOfPattern afterDisabled@"(--|/)debug(\+|:full|:pdbonly)?"
510-
lastIndexOfPattern afterDisabled@"(--|/)g"]|> List.max
511-
idxEnabled> idxDisabled
512-
513-
// checks if combined arg string results in optimizations on/off
514-
letoptimizationsEnabled(args:string)=
515-
// FSI default is --optimize+, so disabling must be explicit
516-
match lastIndexOfPattern args@"(--|/)optimize-"with
517-
|-1->true
518-
| idxDisabled->
519-
// check if it's enabled by later args
520-
letafterDisabled= args.Substring(idxDisabled+5)
521-
letidxEnabled= lastIndexOfPattern afterDisabled@"(--|/)optimize\+?"
522-
idxEnabled> idxDisabled
523-
496+
letcheckDebuggability()=
524497
// debug experience is good when optimizations are off and debug info is produced
525-
if debugInfoEnabled sessions.ProcessArgs&&not(optimizationsEnabled sessions.ProcessArgs)then
498+
ifArgParsing.debugInfoEnabled sessions.ProcessArgs&&not(ArgParsing.optimizationsEnabled sessions.ProcessArgs)then
526499
true
527500
else
528-
// otherwise, warn user that debug experience will be degraded
529-
letresult=
530-
VsShellUtilities.ShowMessageBox(
531-
serviceProvider= provider,
532-
message= VFSIstrings.SR.sessionIsNotDebugFriendly(),
533-
title=null,
534-
icon= OLEMSGICON.OLEMSGICON_WARNING,
535-
msgButton= OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL,
536-
defaultButton= OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST
537-
)
538-
539-
// if user picks OK, allow debugging anyways
540-
result=1
501+
match RegistryHelpers.tryReadHKCU(defaultVSRegistryRoot+"\\"+ settingsRegistrySubKey) debugPromptRegistryValuewith
502+
| Some(1)->true// warning dialog suppressed
503+
|_->
504+
let mutablesuppressDiag=false
505+
letresult=
506+
Microsoft.VisualStudio.PlatformUI.MessageDialog.Show(
507+
VFSIstrings.SR.fsharpInteractive(),
508+
VFSIstrings.SR.sessionIsNotDebugFriendly(),
509+
Microsoft.VisualStudio.PlatformUI.MessageDialogCommandSet.YesNo,
510+
VFSIstrings.SR.doNotShowWarningInFuture(),
511+
&suppressDiag
512+
)
513+
514+
if suppressDiag&& result<> Microsoft.VisualStudio.PlatformUI.MessageDialogCommand.Abortthen
515+
RegistryHelpers.writeHKCU(defaultVSRegistryRoot+"\\"+ settingsRegistrySubKey) debugPromptRegistryValue1
541516

517+
// if user picks YES, allow debugging anyways
518+
result= Microsoft.VisualStudio.PlatformUI.MessageDialogCommand.Yes
542519

543520
letonAttachDebugger(sender:obj)(args:EventArgs)=
544521
if checkDebuggability()then

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp