-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make line numbers in the editor optional #879
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
browser/components/CodeEditor.js
Outdated
@@ -50,7 +50,7 @@ export default class CodeEditor extends React.Component { | |||
this.value = this.props.value | |||
this.editor = CodeMirror(this.refs.root, { | |||
value: this.props.value, | |||
lineNumbers: true, | |||
lineNumbers: this.props.lineNumber, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer lineNumbers
as the variable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I prefer lineNumbers
too. I used lineNumber
as it was already used somewhere else in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was already used somewhere else in the code.
Where is it? I could not find it...
Does it mean you chose lineNumber
because there are probabilities to conflict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used for the line numbers in the preview. Here, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should I change it to lineNumbers
?
browser/components/MarkdownEditor.js
Outdated
@@ -213,6 +213,8 @@ class MarkdownEditor extends React.Component { | |||
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14 | |||
let editorIndentSize = parseInt(config.editor.indentSize, 10) | |||
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4 | |||
let editorLineNumber = config.editor.lineNumber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the name editorLineNumber
is appropriate because it's a boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is editorShowLineNumbers
better? Or just showLineNumbers
? Or what do you propose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isLineNumberShown
? Umm, I'm not sure if it's better...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that fits the plural form (lineNumbers
) you suggested...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I often use is
even if the var name is plural, and the prefix is
describes it's a boolean value. isLineNumbersShown
...?
Did you mean this kind of thing?
https://stackoverflow.com/questions/12960554/java-boolean-getters-is-vs-are
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK then. I meant just the language (English) thing. Other than that, I think isLineNumbersShown
is fine.
browser/components/MarkdownEditor.js
Outdated
@@ -213,6 +213,8 @@ class MarkdownEditor extends React.Component { | |||
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14 | |||
let editorIndentSize = parseInt(config.editor.indentSize, 10) | |||
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4 | |||
let editorLineNumber = config.editor.lineNumber | |||
if (editorLineNumber === undefined) editorLineNumber = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const editorLineNumber = config.editor.lineNumber || true
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If config.editor.lineNumber
were false
(disabled), config.editor.lineNumber || true
would be true
. I don't think that's what you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are cases that config.editor.lineNumber
to be undefined
? The setting should be true
or false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, of course, you are right. I used that before I declared the property in the ConfigManager.js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If config.editor.lineNumber were false (disabled), config.editor.lineNumber || true would be true. I don't think that's what you want.
I got it.
const editorLineNumber = config.editor.lineNumber === undefined ? config.editor.lineNumber : true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, sorry. The variable can't be undefined (as you said), can it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I was confused, too lol
Forget about the ternary operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can just use config.editor.lineNumber
directly here, I think 😄 .
@@ -530,6 +530,7 @@ class SnippetNoteDetail extends React.Component { | |||
fontSize={editorFontSize} | |||
indentType={config.editor.indentType} | |||
indentSize={editorIndentSize} | |||
lineNumber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought Snippet notes should always have line numbers. Shouldn't they?
(lineNumber
is equal to lineNumber={true}
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a little regarding the specification.
(lineNumber is equal to lineNumber={true}.)
Understood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So do you want Snippet notes to respect this setting or should they always show the line numbers?
Hi @asmsuechan and @xxdavid , how is this state? |
@kazup01, I'm waiting for @asmsuechan to tell what we have agreed on and what to change. |
browser/components/CodeEditor.js
Outdated
@@ -141,6 +141,10 @@ export default class CodeEditor extends React.Component { | |||
this.editor.setOption('indentWithTabs', this.props.indentType !== 'space') | |||
} | |||
|
|||
if (prevProps.lineNumber !== this.props.lineNumber) { | |||
this.editor.setOption('lineNumbers', this.props.lineNumber) | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can set even if prevProps.lineNumber !== this.props.lineNumber
is false.
Is it for performance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is and as you can see, the checks are performed for all the options in the componentDidUpdate method.
@xxdavid Hi! I'm one of maintainers of Boostnote. |
Hi @asmsuechan , we are waiting for your reply. Could you check @xxdavid's comments ? |
Sorry for still not updating the PR, but I'm unsure about the variable naming ( |
@xxdavid just in case you are still pondering on the variable naming: maybe consider the name i would also suggest handling the snippets separately (as in: new ticket/discussion, new pull request). that way this pull request could be closed while still keeping the discussion/issue alive. |
@sferra, yeah, I agree, this suits the purpose best in my opinion. |
I've pushed the changes. I also changed snippet notes to respect the option. |
@xxdavid |
Add an option to disable the line numbers in the Markdown editor.