Skip to content
This repository was archived by the owner on Apr 12, 2026. It is now read-only.
/ nppFSIPlugin Public archive
forked from ppv/NPPFSIPlugin

Commit ad4048b

Browse files
committed
Improve UX when changing lexer properties
Unsetting the global 'fold' property still requires reloading, a potentially destructive action, so just warn the user instead Also drops a redundant save action from the config manager's destructor
1 parent 9b74de1 commit ad4048b

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

Source/Plugin/Forms/ConfigForm.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ procedure TFrmConfiguration.initialize;
164164
chkEchoText.Checked := _config.EchoNPPTextInEditor;
165165
with TLexerProperties do
166166
begin
167-
chkFolding.Checked := Fold;
168167
chkFoldCompact.Checked := FoldCompact;
169168
chkFoldComments.Checked := FoldComments;
170169
chkFoldMultiLineComments.Checked := FoldMultiLineComments;
171170
chkFoldOpenStatements.Checked := FoldOpenStatements;
172171
chkFoldPreprocessor.Checked := FoldPreprocessor;
172+
chkFolding.Checked := Fold;
173173
end;
174174

175175
toggleFoldOptions;

Source/Plugin/Src/Config.pas

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ interface
3333

3434
type
3535

36+
TPropertyInt = Boolean;
37+
3638
/// <summary>
3739
/// Stores, retrieves and manages configuration for the plugin.
3840
/// </summary>
3941
TConfiguration = class
4042
private
4143
_configFile: WideString;
42-
_useDotnet: Boolean;
44+
_useDotnet: TPropertyInt;
4345
_fsiPath: String;
4446
_fsiArgs: String;
45-
_convertTabsToSpacesInFSIEditor: Boolean;
47+
_convertTabsToSpacesInFSIEditor: TPropertyInt;
4648
_tabLength: Integer;
47-
_echoNPPTextInEditor: Boolean;
49+
_echoNPPTextInEditor: TPropertyInt;
50+
_initialFoldState: TPropertyInt;
4851
private
4952
procedure initializeConfiguration;
5053
public
@@ -63,8 +66,6 @@ TConfiguration = class
6366
property EchoNPPTextInEditor: Boolean read _echoNPPTextInEditor write _echoNPPTextInEditor;
6467
end;
6568

66-
TPropertyInt = Boolean;
67-
6869
TLexerProperties = class
6970
private
7071
class function GetXMLConfig: WideString; static;
@@ -111,8 +112,6 @@ constructor TConfiguration.Create;
111112

112113
destructor TConfiguration.Destroy;
113114
begin
114-
SaveToConfigFile;
115-
116115
inherited;
117116
end;
118117

@@ -139,6 +138,7 @@ procedure TConfiguration.LoadFromConfigFile;
139138
end;
140139
end;
141140
TLexerProperties.LoadProperties;
141+
_initialFoldState := TLexerProperties.Fold;
142142
end;
143143

144144
procedure TConfiguration.SaveToConfigFile;
@@ -157,6 +157,10 @@ procedure TConfiguration.SaveToConfigFile;
157157
finally
158158
configINI.Free;
159159
end;
160+
TLexerProperties.SetLexer;
161+
if (_initialFoldState = True) and (not TLexerProperties.Fold) then
162+
MessageBoxW(NppData._nppHandle, PWchar('Reload F# files to apply changes.'),
163+
PWchar('File Reload Required'), MB_ICONINFORMATION);
160164
end;
161165

162166
{$ENDREGION}

0 commit comments

Comments
 (0)