diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index e0931df097..a019b1a47b 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -81,6 +81,7 @@ export default class TextualBody extends React.Component { } _applyFormatting() { + const showLineNumbers = SettingsStore.getValue("showCodeLineNumbers"); this.activateSpoilers([this._content.current]); // pillifyLinks BEFORE linkifyElement because plain room/user URLs in the composer @@ -101,8 +102,9 @@ export default class TextualBody extends React.Component { this._handleCodeBlockExpansion(pres[i]); this._addCodeExpansionButton(div, pres[i]); this._addCodeCopyButton(div); - // TODO: Add option to disable this - this._addLineNumbers(pres[i]); + if (showLineNumbers) { + this._addLineNumbers(pres[i]); + } } } // Highlight code diff --git a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js index 636c5cb7c8..e9abe4dbd3 100644 --- a/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js +++ b/src/components/views/settings/tabs/user/PreferencesUserSettingsTab.js @@ -47,6 +47,7 @@ export default class PreferencesUserSettingsTab extends React.Component { 'showRedactions', 'enableSyntaxHighlightLanguageDetection', 'expandCodeByDefault', + 'showCodeLineNumbers', 'showJoinLeaves', 'showAvatarChanges', 'showDisplaynameChanges', diff --git a/src/settings/Settings.ts b/src/settings/Settings.ts index f6af68bedd..b3601213bf 100644 --- a/src/settings/Settings.ts +++ b/src/settings/Settings.ts @@ -305,6 +305,11 @@ export const SETTINGS: {[setting: string]: ISetting} = { displayName: _td('Expand code blocks by default'), default: false, }, + "showCodeLineNumbers": { + supportedLevels: LEVELS_ACCOUNT_SETTINGS, + displayName: _td('Show line numbers in code blocks'), + default: true, + }, "Pill.shouldShowPillAvatar": { supportedLevels: LEVELS_ACCOUNT_SETTINGS, displayName: _td('Show avatars in user and room mentions'),