From c75de19110169746120b0ecc4d749c333a00adca Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 15 Jun 2016 08:36:21 +0200 Subject: [PATCH] fix #46, The generic highlighter is not selected when saving a non D file --- src/ce_main.lfm | 1 - src/ce_main.pas | 14 +++++++++----- src/ce_synmemo.pas | 6 +++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/ce_main.lfm b/src/ce_main.lfm index da9450ba..f025c0bc 100644 --- a/src/ce_main.lfm +++ b/src/ce_main.lfm @@ -4356,7 +4356,6 @@ object CEMainForm: TCEMainForm Images = imgList OnUpdate = ActionsUpdate left = 32 - top = 1 object actEdCopy: TAction Category = 'Edit' Caption = 'Copy' diff --git a/src/ce_main.pas b/src/ce_main.pas index 8df1d3bc..c7814740 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -2663,12 +2663,16 @@ begin end; procedure TCEMainForm.saveProjSource(const aEditor: TCESynMemo); +var + fname: string; begin if fProject = nil then exit; if fProject.filename <> aEditor.fileName then exit; // - aEditor.saveToFile(fProject.filename); - openProj(fProject.filename); + fname := fProject.filename; + fProject.getProject.Free; + aEditor.saveToFile(fname); + openProj(fname); end; procedure TCEMainForm.closeProj; @@ -2755,9 +2759,8 @@ end; procedure TCEMainForm.actProjCloseExecute(Sender: TObject); begin - if (fProject <> nil) and not fProject.inGroup and - fProject.modified and - (dlgFileChangeClose(fProject.filename) = mrCancel) then exit; + if (fProject <> nil) and not fProject.inGroup and fProject.modified and + (dlgFileChangeClose(fProject.filename) = mrCancel) then exit; closeProj; end; @@ -2812,6 +2815,7 @@ begin if not fProject.filename.fileExists then exit; // openFile(fProject.filename); + fDoc.isProjectDescription := true; if fProject.getFormat = pfNative then fDoc.Highlighter := LfmSyn else diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index aa937d49..e8374c9d 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -146,6 +146,7 @@ type fDetectIndentMode: boolean; fPhobosDocRoot: string; fAlwaysAdvancedFeatures: boolean; + fIsProjectDescription: boolean; procedure decCallTipsLvl; procedure setMatchOpts(value: TIdentifierMatchOptions); function getMouseFileBytePos: Integer; @@ -226,6 +227,7 @@ type property isTemporary: boolean read getIfTemp; property TextView; // + property isProjectDescription: boolean read fIsProjectDescription write fIsProjectDescription; property alwaysAdvancedFeatures: boolean read fAlwaysAdvancedFeatures write fAlwaysAdvancedFeatures; property phobosDocRoot: string read fPhobosDocRoot write fPhobosDocRoot; property detectIndentMode: boolean read fDetectIndentMode write fDetectIndentMode; @@ -1529,7 +1531,9 @@ begin ext := aFilename.extractFileExt; fIsDsource := hasDlangSyntax(ext); if fIsDsource then - Highlighter := fD2Highlighter; + Highlighter := fD2Highlighter + else if not isProjectDescription then + Highlighter := TxtHighlighter; FileAge(fFilename, fFileDate); fModified := false; if fFilename <> fTempFileName then