Hide surround with behind a setting

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-02-12 07:53:09 +01:00
parent e90f5ddf5b
commit b330dd55a0
No known key found for this signature in database
GPG key ID: 9760693FDD98A790
3 changed files with 8 additions and 1 deletions

View file

@ -418,6 +418,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
};
private onKeyDown = (event: React.KeyboardEvent) => {
const surroundWith = SettingsStore.getValue("MessageComposerInput.surroundWith");
const selectionRange = getRangeForSelection(this.editorRef.current, this.props.model, document.getSelection());
// trim the range as we want it to exclude leading/trailing spaces
selectionRange.trim();
@ -475,7 +476,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
});
handled = true;
// autocomplete or enter to send below shouldn't have any modifier keys pressed.
} else if (document.getSelection().type != "Caret") {
} else if (surroundWith && document.getSelection().type != "Caret") {
if (event.key === '(') {
this.historyManager.ensureLastChangesPushed(this.props.model);
this.modifiedFlag = true;