Skip to content

Commit 959a936

Browse files
committed
Closes #3016 adds setting to control dismiss on ESC
1 parent 006a326 commit 959a936

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- Adds a `gitlens.fileAnnotations.dismissOnEscape` setting to specify whether pressing the `ESC` key dismisses the active file annotations — closes [#3016](https://github.com/gitkraken/vscode-gitlens/issues/3016)
12+
913
## [14.6.1] - 2023-12-14
1014

1115
### Fixed
@@ -98,7 +102,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
98102
- View Cloud Patches from URLs shared to you and apply them to your working tree or to a new or existing branch
99103
- Manage your Cloud Patches from the new _Cloud Patches_ view in the GitLens side bar
100104
- Adds a _Share as Cloud Patch..._ command to the command palette and to the _Share_ submenu in applicable GitLens views
101-
- Adds a `gitlens.cloudPatches.enabled` setting to specificy whether to enable Cloud Patches (defaults to `true`)
105+
- Adds a `gitlens.cloudPatches.enabled` setting to specify whether to enable Cloud Patches (defaults to `true`)
102106
- Adds support to open multiple instances of the _Commit Graph_, _Focus_, and _Visual File History_ in the editor area
103107
- Adds a _Split Commit Graph_ command to the _Commit Graph_ tab context menu
104108
- Adds a `gitlens.graph.allowMultiple` setting to specify whether to allow opening multiple instances of the _Commit Graph_ in the editor area

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4401,6 +4401,13 @@
44014401
"scope": "window",
44024402
"order": 40
44034403
},
4404+
"gitlens.fileAnnotations.dismissOnEscape": {
4405+
"type": "boolean",
4406+
"default": true,
4407+
"markdownDescription": "Specifies whether pressing the `ESC` key dismisses the active file annotations",
4408+
"scope": "window",
4409+
"order": 45
4410+
},
44044411
"gitlens.fileAnnotations.command": {
44054412
"type": [
44064413
"string",
@@ -15299,7 +15306,7 @@
1529915306
{
1530015307
"command": "gitlens.key.escape",
1530115308
"key": "escape",
15302-
"when": "gitlens:key:escape && editorTextFocus && !findWidgetVisible && !quickFixWidgetVisible && !renameInputVisible && !suggestWidgetVisible && !isInEmbeddedEditor"
15309+
"when": "gitlens:key:escape && editorTextFocus && !findWidgetVisible && !quickFixWidgetVisible && !renameInputVisible && !suggestWidgetVisible && !referenceSearchVisible && !codeActionMenuVisible && !parameterHintsVisible && !isInEmbeddedEditor"
1530315310
},
1530415311
{
1530515312
"command": "gitlens.gitCommands",

src/annotations/fileAnnotationController.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ export class FileAnnotationController implements Disposable {
111111
this.updateDecorations(false);
112112
}
113113

114+
if (configuration.changed(e, 'fileAnnotations.dismissOnEscape')) {
115+
if (configuration.get('fileAnnotations.dismissOnEscape')) {
116+
if (window.visibleTextEditors.some(e => this.getProvider(e))) {
117+
void this.attachKeyboardHook();
118+
}
119+
} else {
120+
void this.detachKeyboardHook();
121+
}
122+
}
123+
114124
let toggleMode;
115125
if (configuration.changed(e, 'blame.toggleMode')) {
116126
toggleMode = configuration.get('blame.toggleMode');
@@ -426,6 +436,8 @@ export class FileAnnotationController implements Disposable {
426436
}
427437

428438
private async attachKeyboardHook() {
439+
if (!configuration.get('fileAnnotations.dismissOnEscape')) return;
440+
429441
// Allows pressing escape to exit the annotations
430442
if (this._keyboardScope == null) {
431443
this._keyboardScope = await this.container.keyboard.beginScope({

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export interface Config {
7979
};
8080
readonly fileAnnotations: {
8181
readonly command: string | null;
82+
readonly dismissOnEscape: boolean;
8283
};
8384
readonly focus: {
8485
readonly allowMultiple: boolean;

0 commit comments

Comments
 (0)