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

Fix #3130: Move line up/down has incorrect behavior in edge cases in inline editor - #3233

Merged
jasonsanjose merged 6 commits into
adobe:masterfrom
TomMalbran:tom/fix-issue-3130
Apr 17, 2013
Merged

jasonsanjose merged 6 commits into
adobe:masterfrom
TomMalbran:tom/fix-issue-3130

Conversation

@TomMalbran

Copy link
Copy Markdown
Contributor

Added 2 special cases making it possible to move the second to last line to the last position and to move the last line up without shrinking the editor.

Currently it would be possible to move the last line to end of file or the line before the end of file, but isn't possible to move before the first line since the TexRange doesn't update to reduce the first line of the inline editor. Anyway, this makes it work better than before and maybe with a new implementation of inline editors, we could remove all the restriction and special cases on inline editors.

@peterflynn

Copy link
Copy Markdown
Member

We should definitely add unit tests for these cases too. See usage of makeEditorWithRange() in EditorCommandHandlers-test for examples of testing edit commands within inline editors.

@TomMalbran

Copy link
Copy Markdown
Contributor Author

Sure, I will add some tests here.

@peterflynn

Copy link
Copy Markdown
Member

Thanks!

@TomMalbran

Copy link
Copy Markdown
Contributor Author

I started working on the tests, but makeEditorWithRange doesn't work for all the cases, since the checks if it is working in an inline editor or not by checking if EditorManager.getFocusedInlineWidget() is not null, and with makeEditorWithRange it will always return null.

I also tried to see if it worked without any special cases, and it does, so even fixing that, these wouldn't make good test cases. Is there another way of really testing an inline editor without creating a window?

@TomMalbran

Copy link
Copy Markdown
Contributor Author

I ended creating a window with an inline editor to do the tests, and used the same window for all the tests, so it doesn't make the tests that much slower. If there is a better alternative, I'll change the tests.

@ghost ghost assigned jasonsanjose Apr 9, 2013
@jasonsanjose

Copy link
Copy Markdown
Member

Assigned to me. Tagging bug #3130.

Comment thread test/spec/EditorCommandHandlers-test.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add this.category = "integration"; to this suite so that it runs in the integration suite instead of the unit test suite. It's our hack to keep the unit test suite running fast. All of our tests that open a Brackets window are marked as integration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do. I knew about this, but didn't knew it could be added to internal describes or if it would be needed, since the tests are still fast, and the Extension Dialog tests uses windows and are unit tests.

@jasonsanjose

Copy link
Copy Markdown
Member

Initial review complete

Comment thread test/spec/EditorCommandHandlers-test.js Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added the _codeMirror.doc.historySize() here too since is a no-op edit too, but since there was a editor.document.setText after the last test, it has to be 1 instead of 0.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see. To make this consistent and expect zero, I'd rather change the afterEach() to close all documents in the working set. You could then change beforeEach to keep the same window open, but always re-create the working set and open the inline widget. Sound good?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is ok too, I did that for the Editor options handlers tests so I can grab some code from there.

@TomMalbran

Copy link
Copy Markdown
Contributor Author

@jasonsanjose Fixes after initial review pushed.

@jasonsanjose

Copy link
Copy Markdown
Member

@TomMalbran one more suggestion on the unit tests before merging.

@TomMalbran

Copy link
Copy Markdown
Contributor Author

@jasonsanjose Fix pushed. I used the same solution as in the CommandOptionHandlers tests to close the documents.

@jasonsanjose

Copy link
Copy Markdown
Member

Looks good. Merging.

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.

3 participants