Skip to content

Commit 25c2706

Browse files
zaneduffieldfourls
authored andcommitted
Skip formatting for unsupported file types
1 parent 3c3829d commit 25c2706

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
* Ignore formatting requests for files without matching file extensions (pas, dpr, dpk, inc).
13+
1014
## [0.2.0] - 2025-03-18
1115

1216
### Added

Pasfmt.FormatEditor.pas

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ implementation
2727
Pasfmt.Log,
2828
System.StrUtils,
2929
Vcl.Dialogs,
30-
System.UITypes;
30+
System.UITypes,
31+
System.IOUtils;
3132

3233
//______________________________________________________________________________________________________________________
3334

@@ -89,8 +90,14 @@ procedure TEditBufferFormatter.Format(Buffer: IOTAEditBuffer);
8990
SourceEditor: IOTAEditorContent;
9091
DebuggerServices: IOTADebuggerServices;
9192
Cursors: TCursors;
93+
Extension: string;
9294
begin
93-
if not Supports(Buffer, IOTAEditorContent, SourceEditor) then begin
95+
Extension := TPath.GetExtension(Buffer.FileName);
96+
if not MatchText(Extension, ['.pas', '.dpr', '.dpk', '.inc']) then begin
97+
Log.Debug('Format request ignored: unsupported file extension "%s"', [Extension]);
98+
Exit;
99+
end
100+
else if not Supports(Buffer, IOTAEditorContent, SourceEditor) then begin
94101
Log.Debug('Format request ignored: the editor is not formattable', [Buffer.FileName]);
95102
Exit;
96103
end

0 commit comments

Comments
 (0)