Skip to content

Commit 005725b

Browse files
committed
Suggest Widget status bar for microsoft#39441
Squashed commit of the following: commit 70b0382 Author: Johannes Rieken <johannes.rieken@gmail.com> Date: Fri Jan 24 16:41:06 2020 +0100 update statusbar with "real" keybindings commit d413a30 Author: Pine Wu <octref@gmail.com> Date: Fri Jan 24 15:31:55 2020 +0100 Polish commit a1bd86c Author: Pine Wu <octref@gmail.com> Date: Fri Jan 24 12:25:32 2020 +0100 Simple StatusBar for suggest
1 parent 7ec3c52 commit 005725b

6 files changed

Lines changed: 175 additions & 27 deletions

File tree

src/vs/editor/common/config/editorOptions.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,6 +2668,10 @@ export interface ISuggestOptions {
26682668
* Show snippet-suggestions.
26692669
*/
26702670
showSnippets?: boolean;
2671+
/**
2672+
* Controls the visibility of the status bar at the bottom of the suggest widget.
2673+
*/
2674+
hideStatusBar?: boolean;
26712675
}
26722676

26732677
export type InternalSuggestOptions = Readonly<Required<ISuggestOptions>>;
@@ -2709,6 +2713,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
27092713
showFolders: true,
27102714
showTypeParameters: true,
27112715
showSnippets: true,
2716+
hideStatusBar: true
27122717
};
27132718
super(
27142719
EditorOption.suggest, 'suggest', defaults,
@@ -2893,6 +2898,11 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
28932898
type: 'boolean',
28942899
default: true,
28952900
markdownDescription: nls.localize('editor.suggest.showSnippets', "When enabled IntelliSense shows `snippet`-suggestions.")
2901+
},
2902+
'editor.suggest.hideStatusBar': {
2903+
type: 'boolean',
2904+
default: true,
2905+
markdownDescription: nls.localize('editor.suggest.hideStatusBar', "Controls the visibility of the status bar at the bottom of the suggest widget.")
28962906
}
28972907
}
28982908
);
@@ -2937,6 +2947,7 @@ class EditorSuggest extends BaseEditorOption<EditorOption.suggest, InternalSugge
29372947
showFolders: EditorBooleanOption.boolean(input.showFolders, this.defaultValue.showFolders),
29382948
showTypeParameters: EditorBooleanOption.boolean(input.showTypeParameters, this.defaultValue.showTypeParameters),
29392949
showSnippets: EditorBooleanOption.boolean(input.showSnippets, this.defaultValue.showSnippets),
2950+
hideStatusBar: EditorBooleanOption.boolean(input.hideStatusBar, this.defaultValue.hideStatusBar),
29402951
};
29412952
}
29422953
}

src/vs/editor/contrib/suggest/media/suggest.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,49 @@
111111
font-weight: bold;
112112
}
113113

114+
/** Status Bar **/
115+
116+
.monaco-editor .suggest-widget > .tree {
117+
margin-bottom: 18px;
118+
}
119+
.monaco-editor .suggest-widget > .suggest-status-bar {
120+
visibility: hidden;
121+
122+
position: absolute;
123+
left: 0;
124+
125+
box-sizing: border-box;
126+
127+
display: flex;
128+
flex-flow: row nowrap;
129+
justify-content: space-between;
130+
131+
width: 100%;
132+
133+
font-size: 80%;
134+
135+
border-left-width: 1px;
136+
border-left-style: solid;
137+
border-right-width: 1px;
138+
border-right-style: solid;
139+
border-bottom-width: 1px;
140+
border-bottom-style: solid;
141+
142+
padding: 1px 8px 1px 4px;
143+
144+
box-shadow: 0 -.5px 3px #ddd;
145+
}
146+
.monaco-editor .suggest-widget > .suggest-status-bar span {
147+
opacity: 0.7;
148+
}
149+
.monaco-editor .suggest-widget.list-right.docs-side > .suggest-status-bar {
150+
left: auto;
151+
right: 0;
152+
}
153+
.monaco-editor .suggest-widget.docs-side > .suggest-status-bar {
154+
width: 50%;
155+
}
156+
114157
/** ReadMore Icon styles **/
115158

116159
.monaco-editor .suggest-widget .details > .monaco-scrollable-element > .body > .header > .codicon-close,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
.monaco-editor .suggest-widget.with-status-bar .suggest-status-bar {
7+
visibility: visible;
8+
}
9+
10+
.monaco-editor .suggest-widget.with-status-bar .suggest-status-bar span {
11+
min-height: 18px;
12+
}
13+
14+
.monaco-editor .suggest-widget.with-status-bar .monaco-list .monaco-list-row > .contents > .main > .right > .readMore,
15+
.monaco-editor .suggest-widget.with-status-bar .monaco-list .monaco-list-row.focused > .contents > .main > .right:not(.always-show-details) > .readMore {
16+
display: none;
17+
}
18+
19+
.monaco-editor .suggest-widget.with-status-bar:not(.docs-side) .monaco-list .monaco-list-row:hover > .contents > .main > .right.can-expand-details > .details-label {
20+
width: 100%;
21+
}

src/vs/editor/contrib/suggest/suggestController.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { SuggestRangeHighlighter } from 'vs/editor/contrib/suggest/suggestRangeH
4343
* Stop suggest widget from disappearing when clicking into other areas
4444
* For development purpose only
4545
*/
46-
const _sticky = false;
46+
const _sticky = true;
4747

4848
class LineSuffix {
4949

@@ -528,11 +528,8 @@ const SuggestCommand = EditorCommand.bindToContribution<SuggestController>(Sugge
528528
registerEditorCommand(new SuggestCommand({
529529
id: 'acceptSelectedSuggestion',
530530
precondition: SuggestContext.Visible,
531-
handler(x, args) {
532-
const alternative: boolean = typeof args === 'object' && typeof args.alternative === 'boolean'
533-
? args.alternative
534-
: false;
535-
x.acceptSelectedSuggestion(true, alternative);
531+
handler(x) {
532+
x.acceptSelectedSuggestion(true, false);
536533
}
537534
}));
538535

@@ -552,16 +549,23 @@ KeybindingsRegistry.registerKeybindingRule({
552549
weight
553550
});
554551

552+
// todo@joh control enablement via context key
555553
// shift+enter and shift+tab use the alternative-flag so that the suggest controller
556554
// is doing the opposite of the editor.suggest.overwriteOnAccept-configuration
557-
KeybindingsRegistry.registerKeybindingRule({
558-
id: 'acceptSelectedSuggestion',
559-
when: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus),
560-
primary: KeyMod.Shift | KeyCode.Tab,
561-
secondary: [KeyMod.Shift | KeyCode.Enter],
562-
args: { alternative: true },
563-
weight
564-
});
555+
registerEditorCommand(new SuggestCommand({
556+
id: 'acceptAlternativeSelectedSuggestion',
557+
precondition: ContextKeyExpr.and(SuggestContext.Visible, EditorContextKeys.textInputFocus),
558+
kbOpts: {
559+
weight: weight,
560+
kbExpr: EditorContextKeys.textInputFocus,
561+
primary: KeyMod.Shift | KeyCode.Enter,
562+
secondary: [KeyMod.Shift | KeyCode.Tab],
563+
},
564+
handler(x) {
565+
x.acceptSelectedSuggestion(false, true);
566+
},
567+
}));
568+
565569

566570
// continue to support the old command
567571
CommandsRegistry.registerCommandAlias('acceptSelectedSuggestionOnEnter', 'acceptSelectedSuggestion');

0 commit comments

Comments
 (0)