Skip to content
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

Fix user preferences not being considered for Text Editor #10868

Merged
merged 9 commits into from Sep 15, 2021

Conversation

Mithil467
Copy link
Member

@Mithil467 Mithil467 commented Aug 18, 2021

References

With reference to issue #9623

Code changes

After this change, all the features like tabSize, fontSize, etc are working. But the features lineNumbers, lineWrap and matchBrackets are not working.

I removed this if condition and everything works fine now.

if (!transientConfigs.includes(key)) {

Another issue I noticed is that the system defaults says "lineNumbers": true but the value used is actually false.
image

Hence I've changed the default value to true here.

lineNumbers: false,


Fixed by #10880

I tried printing the settings object used in the following line -

...(settings.get('editorConfig').composite as JSONObject)

and got the following output -

image

There's no editorConfig attribute and it is not adding anything to config. However, settings.raw containts the JSON we need.

So I replaced the above line of code to -

...(JSON.parse(settings.raw).editorConfig)

@jupyterlab-dev-mode
Copy link

Thanks for making a pull request to JupyterLab!

To try out this branch on binder, follow this link: Binder

@welcome
Copy link

welcome bot commented Aug 18, 2021

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@Mithil467 Mithil467 changed the title Editor Fix user preferences not being considered for Text Editor Aug 18, 2021
@krassowski
Copy link
Member

Indeed on the master branch there seems to be an issue with parsing user config - only toolbar is present and composite is undefined:

Screenshot from 2021-08-18 20-14-46

We need to fix the underlying issue.

@fcollonval
Copy link
Member

Thanks for the analysis @Mithil467 and @krassowski

The absence of composite is probably related to the transformation introduced with #10469.

But the other part directly related to the issue #9623 is linked to the transient configuration introduced in #7611.
I assume the idea was to allow to change some configuration (line number, word wrapping and bracket matching) on an editor basis through the View menu.

So the question is should what should we do when settings are changed for editors that are not using the default value?

pinging @ajbozarth who implemented the transient feature.

@ajbozarth
Copy link
Contributor

I'll try to find time to take a look at this later in the week. From reading discussions #10880 may have solved the problem that prevented me from making them global (rather than transient) in my initial work, which was my preference at the time. In which case I would support this solution. But I will need to test the use cases that caused me to find and fix the issue (easily surfaced in Elyra's script editor)

Copy link
Contributor

@ajbozarth ajbozarth left a comment

Choose a reason for hiding this comment

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

So I've tested this locally and I believe my previous statement holds, this LGTM

@fcollonval
Copy link
Member

Thanks for testing @ajbozarth

Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

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

@Mithil467 could you please rebase this PR, apply the suggestions and check that it has the expected behavior?

@@ -806,7 +806,7 @@ export namespace CodeEditor {
fontFamily: null,
fontSize: null,
lineHeight: null,
lineNumbers: false,
lineNumbers: true,
Copy link
Member

Choose a reason for hiding this comment

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

Please do not change the default setting.

Suggested change
lineNumbers: true,
lineNumbers: false,

Copy link
Member Author

@Mithil467 Mithil467 Sep 2, 2021

Choose a reason for hiding this comment

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

I had done this as a quick fix to this issue where as we see the lineNumbers: true is set in System Defaults but actually the line numbers is false -
image

Copy link
Member

Choose a reason for hiding this comment

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

You are right - this was an inconsistency. And now the UI test are failing because your fix is removing the inconsistency by changing the default.
Sorry for the wrong comment, could you revert to lineNumbers: true so the default behavior stays the same (aka the editor displays line numbers by default).

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, alright!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot @Mithil467

Copy link
Member Author

@Mithil467 Mithil467 Sep 5, 2021

Choose a reason for hiding this comment

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

Oh maybe you are talking about the predefined configuration for User Preferences? I actually had overwritten the User Preferences. I deleted the ~/.jupyter folder to reset the user settings and turns out that it is empty by default with just {}.

Copy link
Member

Choose a reason for hiding this comment

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

Hey @Mithil467 sorry for the late reply. To clean your user settings, you need to remove the settings in %USERPROFILE%.jupyter\lab\user-settings (if on Windows), $HOME/.jupyter/lab/user-settings (otherwise).

So yes we need to figure out why the default configuration for all editors (in the notebook and in the text file) are taken instead of the default settings that should allow to have line numbers in text file by default but not in notebook cells.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see! I already deleted the mentioned ~/.jupyter folder and then when I see the user preferences it is empty.
image

Copy link
Member Author

Choose a reason for hiding this comment

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

Apparently there is no file called lab\user-settings inside the .jupyter folder

Copy link
Member Author

Choose a reason for hiding this comment

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

The user preferences are not set by default on a fresh installation as per the gitter conversation with @jasongrout. I guess for moving ahead we can either

  1. Set this to false -
  2. Or update the galata tests to reflect this change.
    I guess the second option will help resolving this https://discourse.jupyter.org/t/permanently-activate-line-numbers-in-editor/3864/3 too.

packages/fileeditor-extension/src/commands.ts Outdated Show resolved Hide resolved
@Mithil467
Copy link
Member Author

I have rebased master into this editor branch and then run Jupyterlab. Seems like everything is working as expected!

@meeseeksmachine
Copy link
Contributor

This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there:

https://discourse.jupyter.org/t/permanently-activate-line-numbers-in-editor/3864/3

@krassowski
Copy link
Member

I just want to highlight that the failing tests caught an actual regression (in addition to the behaviour change that is under discussion) in the TOC you can see that the line numbers now appear over the code, whereas the old implementation assumed these are not there:

toggle-code-actual

The diff:

toggle-code-diff

@Mithil467
Copy link
Member Author

Should I update the UI regression test with the new images (except for the above regression)?

@blink1073 blink1073 added the bug label Sep 11, 2021
@fcollonval
Copy link
Member

Ok I figure out what was the trouble. If the user settings define partially the editor configuration or the cell configuration, the default values for the other properties won't be used (as the top configuration exists even if it is empty like in that comment).

So I revert the default value for the line numbers in the code. And I set default values for all properties of the configuration objects.

@Mithil467
Copy link
Member Author

Oh I see, that makes sense

@github-actions
Copy link
Contributor

Benchmark report

The execution time (in milliseconds) are grouped by test file, test type and browser.
For each case, the following values are computed: min <- [1st quartile - median - 3rd quartile] -> max.

Results table
Test file large_code_notebook large_md_notebook
open
chromium
actual 4822 <- [5810 - 5946 - 5992] -> 6743 2689 <- [2759 - 2964 - 2997] -> 3042
expected 6938 <- [7584 - 7618 - 7760] -> 8204 3461 <- [3524 - 3534 - 3590] -> 4136
switch-from
chromium
actual 373 <- [379 - 387 - 395] -> 417 239 <- [260 - 272 - 279] -> 292
expected 464 <- [480 - 489 - 499] -> 789 310 <- [338 - 344 - 352] -> 370
switch-to
chromium
actual 1392 <- [1473 - 1493 - 1542] -> 1610 1240 <- [1278 - 1345 - 1357] -> 1383
expected 1706 <- [1730 - 1764 - 1814] -> 2015 1541 <- [1549 - 1562 - 1574] -> 1608
close
chromium
actual 4606 <- [10749 - 12193 - 12423] -> 12759 2635 <- [2837 - 2961 - 3136] -> 3285
expected 5176 <- [5770 - 10533 - 14493] -> 18824 3325 <- [3691 - 3890 - 3939] -> 4073

❗ Test metadata have changed
--- /dev/fd/63	2021-09-13 15:06:48.199601801 +0000
+++ /dev/fd/62	2021-09-13 15:06:48.199601801 +0000
@@ -8,7 +8,7 @@
   },
   "systemInformation": {
     "cpu": {
-      "brand": "Xeon® Platinum 8272CL",
+      "brand": "Xeon® Platinum 8171M",
       "cache": {
         "l1d": 65536,
         "l1i": 65536,
@@ -28,13 +28,13 @@
       "speed": 2.6,
       "speedMax": null,
       "speedMin": null,
-      "stepping": "7",
+      "stepping": "4",
       "vendor": "GenuineIntel",
       "virtualization": false,
       "voltage": ""
     },
     "mem": {
-      "total": 7291699200
+      "total": 7291695104
     },
     "osInfo": {
       "arch": "x64",
@@ -46,7 +46,7 @@
       "logofile": "ubuntu",
       "platform": "linux",
       "release": "20.04.3 LTS",
-      "serial": "cfc067bfcb844f35865e279a1b0e66c5",
+      "serial": "0f5fd491ff264b5f9d56e03599b4fae0",
       "servicepack": "",
       "uefi": false
     }

@Mithil467
Copy link
Member Author

Mithil467 commented Sep 13, 2021

The test is failing on this -

View image

And then for Retry 1-

Actual
Expected
Diff

@fcollonval fcollonval merged commit d70339d into jupyterlab:master Sep 15, 2021
@fcollonval fcollonval added this to the 3.1.x milestone Sep 15, 2021
@fcollonval
Copy link
Member

@meeseeksdev please backport to 3.1.x

@lumberbot-app
Copy link

lumberbot-app bot commented Sep 15, 2021

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout 3.1.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 d70339dbf6f9cfce65b287fb7e208f052bd2a29b
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #10868: Fix user preferences not being considered for Text Editor'
  1. Push to a named branch :
git push YOURFORK 3.1.x:auto-backport-of-pr-10868-on-3.1.x
  1. Create a PR against branch 3.1.x, I would have named this PR:

"Backport PR #10868 on branch 3.1.x (Fix user preferences not being considered for Text Editor)"

And apply the correct labels and milestones.

Congratulation you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove Still Needs Manual Backport label once the PR gets merged.

If these instruction are inaccurate, feel free to suggest an improvement.

@Mithil467
Copy link
Member Author

Thank you! I'll try to backport this.

Mithil467 added a commit to Mithil467/jupyterlab that referenced this pull request Sep 15, 2021
blink1073 pushed a commit that referenced this pull request Sep 15, 2021
@github-actions github-actions bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Mar 20, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug pkg:fileeditor pkg:notebook status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants