-
Notifications
You must be signed in to change notification settings - Fork 2.8k
ZEPPELIN-219: Paragaph mode auto-detection - initial impl #206
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
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.
reuse the text gotten in aceChanged? how bad is it to get this again?
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 will reuse the text value. Don't know what is the performance implication of calling it again.
|
Note: apparently i didn't commit all changes with the latest commit (40b9a33). Will redo it again. |
7fe3b19 to
ff896a4
Compare
|
I would love to see some unit tests for this. |
|
@djoelz, this change affects paragraph.controller.js. I am not sure i've seen units tests for this or the other js controllers? But i might have missed something. @Leemoonsoo is there some samples for testing such behavior? |
|
Two possible places for test. test controllers and directives or test using selenium |
7a779b0 to
c0cdbc2
Compare
|
@Leemoonsoo thanks for the references. If not mistaken the test controllers and directives doesn't contain any real controller tests at the moment. As i've mentioned earlier i'm not much of js/angular authority and would prefer to learn from someone else's experience and examples. @djoelz do you feel like you can help here? |
|
Maybe I can help with those tests, I guess we need:
|
|
@corneadoug, your help will be well appreciated! The suggested testset sounds good and covering the functionality. |
|
@tzolov I am also new to the angular/js world but if @corneadoug can provide a starting point I can help with the more tests. |
b24f0d5 to
a507e3e
Compare
|
Hi, Sorry guys I'm taking a bit of time on this one. |
|
@corneadoug not sure but think that to be able to see it in "create new PR" ui you need to make sure that the branch you are using is actually derived from https://github.com/tzolov/incubator-zeppelin/tree/ZEPPELIN-219 (either checkouted from ZEPPELIN-219 branch of the clean clone of tzolov/incubator-zeppelin or from the new 'remote' pointing here, inside your existing repo) You can verify it with |
|
I created a remote from his repo, then used his branch as a base. |
|
@tzolov can you merge this into your branch then? https://github.com/corneadoug/incubator-zeppelin/tree/improve/ZEPPELIN-219 |
|
@corneadoug, thanks for the improvements. |
fe37ef9 to
518f009
Compare
|
@corneadoug, have you had chance on writing an unit test(s) for this PR? |
|
@tzolov I started doing it, if possible give me a day to finish it up |
|
@corneadoug, glad to hear you are working on this. Take your time. Your help is highly appreciated and will help me/us learn how to write such tests! |
|
@corneadoug it is done. just rebased (after ZEPPELIN-228) and pushed. |
|
Just spent a lot of time on this. |
|
Thanks for the update @corneadoug. I've faced the ace upgrade issue while preparing the (ZEPPELIN-216). When i tried to upgrade ace to 1.2.0 the existing ui-ace version complained. I've managed to increase ui-ace but had to force some dependency resolutions and was not confident it will not cause side effects. So i upgraded ace to safest ace 1.1.9 version instead. But if you manage to upgrade ui-ace (very outdated it seems) it will allow us upgrade ace-build as well. @Leemoonsoo , @felixcheung it seems that this PR (e.g. ZEPPELIN-219) is ready to merge. |
|
Looks good to me! |
Here are the mode autodetection rules (and optimizations):
- Evaluates the editor mode on each `aceChange` event.
- (Optimization 1) Evaluates the mode only if the cursor is within the first 30 characters of the buffer.
- (Optimization 2) Sets the mode (e.g. `session.setMode(new mode)` ) only if the new mode differs from the previous one.
Also the mode tag detection structure is refactored to bring together the interpreter tag test and the mode reference. The convention looks like this:
```javascript
var editorModes = [
[<Your Mode 1 Reg Expression Test>, <ACE Mode 1>],
......
[<Your Mode N Reg Expression Test>, <ACE Mode N>]
];
```
For example:
```javascript
var editorModes = [
[/^%spark/, 'ace/mode/scala'],
[/^%(\w*\.)?\wql/, 'ace/mode/sql'],
[/^%md/, 'ace/mode/markdown'],
[/^%sh/, 'ace/mode/sh']
];
```
Author: Damien Corneau <[email protected]>
Author: tzolov <[email protected]>
Closes apache#206 from tzolov/ZEPPELIN-219 and squashes the following commits:
fda3f5e [Damien Corneau] Improve loop performances
153f327 [Damien Corneau] Change setParagraphMode function
ea76881 [tzolov] ZEPPELIN-219: Add paragraph text as setPargraphMode() argument
aab3b7c [tzolov] ZEPPELIN-219: Paragaph mode auto-detection - initial impl
(cherry picked from commit eebae39)
Signed-off-by: Lee moon soo <[email protected]>
Here are the mode autodetection rules (and optimizations):
aceChangeevent.session.setMode(new mode)) only if the new mode differs from the previous one.Also the mode tag detection structure is refactored to bring together the interpreter tag test and the mode reference. The convention looks like this:
For example: