Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Open file in pending state on single click - #10178

Merged
nathansobo merged 14 commits into
masterfrom
ku-pending-editor
Jan 8, 2016
Merged

nathansobo merged 14 commits into
masterfrom
ku-pending-editor

Conversation

@kuychaco

Copy link
Copy Markdown
Contributor

Addresses issue #9165

Single-clicking on a file in tree-view or on a search result from find-in-project opens a 'pending tab'.

See corresponding pull requests for tree-view and tabs packages:

Add event methods for 'did-confirm-pending-state'.
Check if isPending function exists on item before invoking.
Only destroy active item if it is not the same as the new item.
Revert to original code to conform to specs.
@nathansobo

Copy link
Copy Markdown
Contributor

I like this better, too. Nice work.

Looks like you still need to thread the option through Workspace.prototype.open and test confirmPendingState and that modifying the buffer also confirms the state.

@lee-dohm

Copy link
Copy Markdown
Contributor

To me "confirm pending state" means that one is confirming that it is pending ... rather than making a pending item not-pending or confirmed. I feel like the term "pending" is causing a naming issue. Is there a reason we can't use the terms "temporary" and "permanent"? (I realize that "pending" came along with the original code, but I can't find the original discussion around the terminology.)

I'm totally 👍 on the API though. Well designed.

@nathansobo

Copy link
Copy Markdown
Contributor

Now that all the methods are on the pane item itself rather than on the pane, maybe something like terminatePendingState works? I avoided it on the initial Pane-oriented API because of concerns about confusion with a pending item being removed, but that's not an issue now.

@lee-dohm

Copy link
Copy Markdown
Contributor

terminatePendingState is much better, thanks 😀

Now it is called onDidTerminatePendingState.
Test not yet passing. ::insertText is not triggering terminatePendingState. Not sure why...
@kuychaco

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback and great suggestions for improving the nomenclature! I changed the code to use "terminate" rather than "confirm".

Looks like you still need to thread the option through Workspace.prototype.open and test confirmPendingState and that modifying the buffer also confirms the state.

No need to make any changes to Workspace::open, it's already set up to handle the pending option. What's nice is that with this approach there's no need to touch the workspace.coffee file.

Added a few tests. The test for modifying the buffer isn't passing because for some reason using ::insertText does not trigger the did-change-modified event that ::terminatePendingState is listening for. Is there another method I should be using to modify the buffer in the test?

@nathansobo

Copy link
Copy Markdown
Contributor

is listening for. Is there another method I should be using to modify the buffer in the test?

It's an async event... the clock is mocked in the global environment and you should be able to use advanceClock to force time ahead until it fires. I'm not stoked about the way that evolved but it should work for now.

@nathansobo

Copy link
Copy Markdown
Contributor

What happens if I single click, then double click a file in the tree view?

@kuychaco

Copy link
Copy Markdown
Contributor Author

Doh! Async, of course... I'm curious to know what you're not stoked about @nathansobo... is there a better way you know of? I tried using waits/runs but it doesn't work:

it "should terminate pending state when buffer is changed", ->
      events = []
      editor1.onDidTerminatePendingState (event) -> events.push(event)
      expect(editor1.isPending()).toBe true
      editor1.insertText('I\'ll be back!')
      waits 500
      runs ->
        expect(editor1.isPending()).toBe false
        expect(events).toEqual [editor1]

I've seen waits being used in other specs and from what I can tell it waits a fixed period of time before moving to the next block. Unsure why it's not working here.

I'd imagine that ideally there be a way that doesn't require hardcoding a somewhat arbitrary amount of time to wait or speed up the clock...

Anyhow, using advanceClock works just fine. Thanks @nathansobo!

@kuychaco

Copy link
Copy Markdown
Contributor Author

Single-clicking and then double-clicking a file in tree view should work as expected - single click opens the file in a pending state, and a subsequent double-click terminates the pending state. (Note that for the double-click the first click re-opens the file as pending and the second click terminates the pending state)

You can view a test verifying this here

Also note that single-clicking a file that is already open does not put the file back in pending state.

@nathansobo

Copy link
Copy Markdown
Contributor

Single-clicking and then double-clicking a file in tree view should work as expected

👍

@nathansobo

Copy link
Copy Markdown
Contributor

Last commit is superficial change. Merging. Congrats @kuychaco on landing your first PR on atom/atom!

nathansobo pushed a commit that referenced this pull request Jan 8, 2016
Open file in pending state on single click
@nathansobo
nathansobo merged commit db74f4a into master Jan 8, 2016
@nathansobo
nathansobo deleted the ku-pending-editor branch January 8, 2016 21:45
@lee-dohm

lee-dohm commented Jan 9, 2016

Copy link
Copy Markdown
Contributor

Congratulations! 🎉

@steelbrain

Copy link
Copy Markdown
Contributor

Note to self: Defer linting on preview tabs

@steelbrain

Copy link
Copy Markdown
Contributor

Is there any config to disable preview tabs? Existing config was removed in atom/tabs

@benogle

benogle commented Feb 10, 2016

Copy link
Copy Markdown
Contributor

Not yet, though we plan to add one and patch it into 1.6 beta

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