-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Provide editor options "line numbers", "active line" and "word wrap" as ... #3097
Conversation
…as new menu items under View menu.
…as new menu items under View menu.
…to rlim/word-wrap
Conflicts: src/editor/Editor.js
Conflicts: src/editor/Editor.js
…to rlim/word-wrap
@@ -101,6 +101,9 @@ | |||
@selection-color-focused: #d2dcf8; | |||
@selection-color-unfocused: #d9d9d9; | |||
|
|||
/* background color of the line that has the cursor */ | |||
@activeline-bgcolor: #e8f2ff; |
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.
@GarthDB -- see if you have any comment on this color.
Now that there is an EditorOptions file, auto close brackets could be moved there too, since is another Editor option command. |
Reassigned to me. Raymond, please fix the merge conflicts. Thanks. |
Conflicts: src/command/Commands.js src/nls/root/strings.js
Done fixing merge conflicts. Ready for review. |
Reviewing |
I'm seeing 6 console errors when starting brackets on this branch. I cleaned my cache and removed all extensions to be sure:
|
Ignore the |
@@ -213,6 +213,7 @@ define({ | |||
"CMD_RESTORE_FONT_SIZE" : "Restore Font Size", | |||
"CMD_SCROLL_LINE_UP" : "Scroll Line Up", | |||
"CMD_SCROLL_LINE_DOWN" : "Scroll Line Down", | |||
"CMD_TOGGLE_WORD_WRAP" : "Enable Word Wrap", |
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.
CMD_TOGGLE_LINE_NUMBERS
and CMD_TOGGLE_ACTIVE_LINE
are missing, causing the console errors I noted earlier.
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.
Somehow I didn't get them in when resolving the conflicts in merging master to my branch.
I'm seeing 2 issues with word wrap that I've filed: codemirror/codemirror5#1361 With word wrap enabled, new trailing spaces are not wrapped I haven't filed new tracking bugs in Brackets. @RaymondLim can you do that? Thanks. |
@@ -1373,6 +1385,60 @@ define(function (require, exports, module) { | |||
return _closeBrackets; | |||
}; | |||
|
|||
/** |
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.
Fix indentation
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.
Good catch! Not sure how I got this in accidentally.
I'm seeing failures in the new unit tests:
|
}); | ||
|
||
runs(function () { | ||
var openAndSelect = function (path) { |
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.
openAndSelect
matches line 176. I think you intended to refactor this into a higher scope and reuse it, right?
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.
Oops. Not really I wanted to have it in a higher scope. I was just copying from other unit test and then duplicate the same code for testing active line.
Ready for third round of review unless @redmunds says I need to do something with the default prefs. |
I'm still not comfortable with not assigning new default preferences, whether it's during migration or during normal startup. I'll take a look at #3101 and see if we can fix the problem there before merging this pull. Sound like a plan @RaymondLim? |
I totally agree with you. I was shocked when I noticed this yesterday morning. So it is definitely not ok for our end users even if we tell them to delete preference cache. |
The preference should be reversed so undefined defaults to what was there before. So, change |
@RaymondLim, @TomMalbran's fix got merged. Looks like there's an conflict in Editor.js. I'm pretty sure the change should now be: |
Yes, and it should also be |
Thanks. I'll fix the conflict soon. |
Conflicts: src/editor/Editor.js
var defaultPrefs = { useTabChar: false, tabSize: 4, indentUnit: 4, closeBrackets: false }; | ||
|
||
defaultPrefs = { useTabChar: false, tabSize: 4, indentUnit: 4, closeBrackets: false, | ||
showLineNumbers: true, styleActiveLine: true, wordWrap: 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.
Missing the var now. Seems like this is what made the build fail.
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.
Thanks. I was unable to launch and still looking for the culprit.
I'm testing preferences as follows
The prefs seem to work correctly, but I'm seeing an error in
|
CommandManager.get(Commands.TOGGLE_LINE_NUMBERS).setChecked(Editor.getShowLineNumbers()); | ||
CommandManager.get(Commands.TOGGLE_ACTIVE_LINE).setChecked(Editor.getShowActiveLine()); | ||
CommandManager.get(Commands.TOGGLE_WORD_WRAP).setChecked(Editor.getWordWrap()); | ||
CommandManager.get(Commands.CMD_TOGGLE_CLOSE_BRACKETS).setChecked(Editor.getCloseBrackets()); |
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.
This should be Commands.TOGGLE_CLOSE_BRACKETS
Good catch! It's my mistake when copying the string from other place. |
@TomMalbran and @RaymondLim and maybe @redmunds, I think I found the issue with the preferences migration. See #3185. This pull looks good, but I would like to merge #3185 and re-test before pulling this in. |
Looks good. Scenario tested sprint 21 to sprint 22 and the preferences migrate properly and the new defaults are added as expected. Merging. |
Provide editor options "line numbers", "active line" and "word wrap" as ...
I saw that there are tests here for word wrap and line highlight. I was thinking that I could add tests for auto close brackets, but wasn't sure how much to test. Should be something like it should auto close when active only or more complex adding the backspace function and others? |
@TomMalbran -- Yes, you're welcome to add unit tests for auto close brackets. Start it with simple ones and then extend it to cover complex ones for backspace handling and not auto close when typing on or inside an existing word later. |
Working on them. I started adding tests for Toggle Line Numbers. I have the problem of trying to mock a key input. Is there anyway to insert some text to an editor and make it treat it as a key input? |
@TomMalbran: SpecRunnerUtils.simulateKeyEvent() may be of some help, although editor input is a tricky case. If you look at CodeHint-test there are several different approaches it uses in various tests. |
Great. Will look into that. Thanks |
...new menu items under View menu.