Skip to content

Commit 5a67a9f

Browse files
committed
feature: supports to exclude some editors (#2033)
Signed-off-by: leo <[email protected]>
1 parent 5690193 commit 5a67a9f

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,19 @@ This app supports open repository in external tools listed in the table below.
176176
| Visual Studio | YES | NO | NO |
177177

178178
> [!NOTE]
179-
> This app will try to find those tools based on some pre-defined or expected locations automatically. If you are using one portable version of these tools, it will not be detected by this app.
180-
> To solve this problem you can add a file named `external_editors.json` in app data storage directory and provide the path directly. For example:
179+
> This app will try to find those tools based on some pre-defined or expected locations automatically. If you are using one portable version of these tools, it will not be detected by this app.
180+
> To solve this problem you can add a file named `external_editors.json` in app data storage directory and provide the path directly.
181+
> User can also exclude some editors by using `external_editors.json`.
182+
183+
The format of `external_editors.json`:
181184
```json
182185
{
183186
"tools": {
184187
"Visual Studio Code": "D:\\VSCode\\Code.exe"
185-
}
188+
},
189+
"excludes": [
190+
"Visual Studio Community 2019"
191+
]
186192
}
187193
```
188194

src/App.JsonCodeGen.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public override void Write(Utf8JsonWriter writer, DataGridLength value, JsonSeri
5959
typeof(DataGridLengthConverter),
6060
]
6161
)]
62-
[JsonSerializable(typeof(Models.ExternalToolPaths))]
62+
[JsonSerializable(typeof(Models.ExternalToolCustomization))]
6363
[JsonSerializable(typeof(Models.HistoryFilterCollection))]
6464
[JsonSerializable(typeof(Models.InteractiveRebaseJobCollection))]
6565
[JsonSerializable(typeof(Models.JetBrainsState))]

src/Models/ExternalTool.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ public class JetBrainsTool
9595
public string LaunchCommand { get; set; }
9696
}
9797

98-
public class ExternalToolPaths
98+
public class ExternalToolCustomization
9999
{
100100
[JsonPropertyName("tools")]
101101
public Dictionary<string, string> Tools { get; set; } = new Dictionary<string, string>();
102+
[JsonPropertyName("excludes")]
103+
public List<string> Excludes { get; set; } = new List<string>();
102104
}
103105

104106
public class ExternalToolsFinder
@@ -117,20 +119,23 @@ public ExternalToolsFinder()
117119
if (File.Exists(customPathsConfig))
118120
{
119121
using var stream = File.OpenRead(customPathsConfig);
120-
_customPaths = JsonSerializer.Deserialize(stream, JsonCodeGen.Default.ExternalToolPaths);
122+
_customization = JsonSerializer.Deserialize(stream, JsonCodeGen.Default.ExternalToolCustomization);
121123
}
122124
}
123125
catch
124126
{
125127
// Ignore
126128
}
127129

128-
_customPaths ??= new ExternalToolPaths();
130+
_customization ??= new ExternalToolCustomization();
129131
}
130132

131133
public void TryAdd(string name, string icon, Func<string> finder, Func<string, string> execArgsGenerator = null)
132134
{
133-
if (_customPaths.Tools.TryGetValue(name, out var customPath) && File.Exists(customPath))
135+
if (_customization.Excludes.Contains(name))
136+
return;
137+
138+
if (_customization.Tools.TryGetValue(name, out var customPath) && File.Exists(customPath))
134139
{
135140
Tools.Add(new ExternalTool(name, icon, customPath, execArgsGenerator));
136141
}
@@ -201,6 +206,6 @@ public void FindJetBrainsFromToolbox(Func<string> platformFinder)
201206
}
202207
}
203208

204-
private ExternalToolPaths _customPaths = null;
209+
private ExternalToolCustomization _customization = null;
205210
}
206211
}

0 commit comments

Comments
 (0)