Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Provide editor options "line numbers", "active line" and "word wrap" as ... #3097

Merged
merged 15 commits into from
Mar 20, 2013

Conversation

RaymondLim
Copy link
Contributor

...new menu items under View menu.

@ghost ghost assigned peterflynn Mar 11, 2013
@@ -101,6 +101,9 @@
@selection-color-focused: #d2dcf8;
@selection-color-unfocused: #d9d9d9;

/* background color of the line that has the cursor */
@activeline-bgcolor: #e8f2ff;
Copy link
Contributor Author

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.

@TomMalbran
Copy link
Contributor

Now that there is an EditorOptions file, auto close brackets could be moved there too, since is another Editor option command.

@ghost ghost assigned jasonsanjose Mar 14, 2013
@jasonsanjose
Copy link
Member

Reassigned to me. Raymond, please fix the merge conflicts. Thanks.

Conflicts:
	src/command/Commands.js
	src/nls/root/strings.js
@RaymondLim
Copy link
Contributor Author

Done fixing merge conflicts. Ready for review.

@jasonsanjose
Copy link
Member

Reviewing

@jasonsanjose
Copy link
Member

I'm seeing 6 console errors when starting brackets on this branch. I cleaned my cache and removed all extensions to be sure:

Attempting to register a command with a missing name, id, or command function:undefined view.toggleLineNumbers command/CommandManager.js:182
Attempting to register a command with a missing name, id, or command function:undefined view.toggleActiveLine command/CommandManager.js:182
Cannot assign Cmd-G to navigate.gotoLine. It is already assigned to edit.findNext command/KeyBindingManager.js:405
addMenuItem(): commandID not found: view.toggleLineNumbers command/Menus.js:485
addMenuItem(): commandID not found: view.toggleActiveLine command/Menus.js:485
Exception when calling a 'brackets done loading' handler: 
TypeError: Cannot call method 'setChecked' of undefined
    at _init (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/editor/EditorOptionHandlers.js:75:58)
    at _callHandler (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/utils/AppInit.js:59:13)
    at Object._dispatchReady (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/utils/AppInit.js:74:13)
    at Object.<anonymous> (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/brackets.js:320:13)
    at Object.g.s.newContext.h.execCb (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:30:455)
    at Object.g.s.newContext.U.check (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:20:302)
    at Object.g.s.newContext.U.enable.c (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:24:331)
    at file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:7:527
    at g.s.newContext.U.emit (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:25:174)
    at t (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:7:178)
    at Object.g.s.newContext.U.emit (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:25:145) utils/AppInit.js:62

@jasonsanjose
Copy link
Member

Ignore the edit.findNext key binding error. That's a known issue.

@@ -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",
Copy link
Member

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.

Copy link
Contributor Author

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.

@jasonsanjose
Copy link
Member

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
codemirror/codemirror5#1362 With word wrap enabled, spaces inside a tag are not rendered

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;
};

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation

Copy link
Contributor Author

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.

@jasonsanjose
Copy link
Member

I'm seeing failures in the new unit tests:

  • should NOT style active line after turning it off
  • should NOT style the active line when opening another document with show active line off

});

runs(function () {
var openAndSelect = function (path) {
Copy link
Member

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?

Copy link
Contributor Author

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.

@RaymondLim
Copy link
Contributor Author

Ready for third round of review unless @redmunds says I need to do something with the default prefs.

@jasonsanjose
Copy link
Member

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?

@RaymondLim
Copy link
Contributor Author

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.

@redmunds
Copy link
Contributor

The preference should be reversed so undefined defaults to what was there before. So, change showLineNumbers to hideLineNumbers.

@jasonsanjose
Copy link
Member

@RaymondLim, @TomMalbran's fix got merged. Looks like there's an conflict in Editor.js. I'm pretty sure the change should now be: PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID, defaults);

@TomMalbran
Copy link
Contributor

Yes, and it should also be PreferencesManager.handleClientIdChange(_prefs, "com.adobe.brackets.Editor");

@RaymondLim
Copy link
Contributor Author

Thanks. I'll fix the conflict soon.

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 };
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@jasonsanjose
Copy link
Member

I'm testing preferences as follows

  1. by clearing out my cache
  2. running sprint 21 (using tools/restore_installed_build.sh) to create an initial set of prefs
  3. quitting brackets
  4. setup this branch (using tools/setup_for_hacking.sh)
  5. launch brackets again

The prefs seem to work correctly, but I'm seeing an error in EditorOptionsHandler when launching:

TypeError: Cannot call method 'setChecked' of undefined
    at _init (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/editor/EditorOptionHandlers.js:78:64)
    at _callHandler (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/utils/AppInit.js:59:13)
    at Object._dispatchReady (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/utils/AppInit.js:74:13)
    at Object.<anonymous> (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/brackets.js:321:13)
    at Object.g.s.newContext.h.execCb (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:30:455)
    at Object.g.s.newContext.U.check (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:20:302)
    at Object.g.s.newContext.U.enable.c (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:24:331)
    at file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:7:527
    at g.s.newContext.U.emit (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:25:174)
    at t (file://localhost/Applications/Brackets%20Sprint%2021.app/Contents/dev/src/thirdparty/require.js:7:178) 

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());
Copy link
Contributor

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

@RaymondLim
Copy link
Contributor Author

Good catch! It's my mistake when copying the string from other place.

@jasonsanjose
Copy link
Member

@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.

@jasonsanjose
Copy link
Member

Looks good. Scenario tested sprint 21 to sprint 22 and the preferences migrate properly and the new defaults are added as expected. Merging.

jasonsanjose added a commit that referenced this pull request Mar 20, 2013
Provide editor options "line numbers", "active line" and "word wrap" as ...
@jasonsanjose jasonsanjose merged commit 0ca4305 into master Mar 20, 2013
@jasonsanjose jasonsanjose deleted the rlim/word-wrap branch March 20, 2013 21:24
@TomMalbran
Copy link
Contributor

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?

@RaymondLim
Copy link
Contributor Author

@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.

@TomMalbran
Copy link
Contributor

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?

@peterflynn
Copy link
Member

@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.

@TomMalbran
Copy link
Contributor

Great. Will look into that. Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants