Skip to content

Commit

Permalink
Prepares for version 2.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebebak committed Nov 9, 2017
1 parent a321bac commit 7851795
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 14 deletions.
8 changes: 4 additions & 4 deletions commands/request.py
Expand Up @@ -541,8 +541,8 @@ def run(self):
binding_info = view.settings().get('requester.binding_info', None)
if binding_info is None:
return
file, old_request = binding_info
if not file or not old_request:
file, original_request = binding_info
if not file or not original_request:
return

try:
Expand All @@ -569,7 +569,7 @@ def save_request():
break
content = requester_view.substr(sublime.Region(0, requester_view.size()))
try:
start_index = content.index(old_request)
start_index = content.index(original_request)
except ValueError as e:
sublime.error_message('Save Error: your original request was modified since you first sent it!')
return
Expand All @@ -578,7 +578,7 @@ def save_request():
# simply calling `requester_view.replace` corrupts `view`s settings
requester_view.run_command(
'requester_replace_text',
{'text': request, 'start_index': start_index, 'end_index': start_index + len(old_request)})
{'text': request, 'start_index': start_index, 'end_index': start_index + len(original_request)})
requester_view.sel().clear()
requester_view.sel().add(sublime.Region(start_index))
if not is_open: # hacky trick to make sure scroll works
Expand Down
4 changes: 2 additions & 2 deletions commands/request_history.py
Expand Up @@ -31,7 +31,7 @@ def load_history(rev=True, as_dict=False):

def populate_staging_view(view, index, total,
request, method, url, code, ts,
meta=None, file=None, env_string=None, env_file=None):
meta=None, file=None, env_string=None, env_file=None, original_request=None):
"""Populate staging view with historical request string/metadata.
"""
from .request import response_tab_bindings, set_save_info_on_view
Expand All @@ -40,7 +40,7 @@ def populate_staging_view(view, index, total,
view.settings().set('requester.file', file)
view.settings().set('requester.env_string', env_string)
view.settings().set('requester.env_file', env_file)
set_save_info_on_view(view, request)
set_save_info_on_view(view, original_request or request)

config = sublime.load_settings('Requester.sublime-settings')
max_len = int(config.get('response_tab_name_length', 32))
Expand Down
8 changes: 7 additions & 1 deletion core/__init__.py
Expand Up @@ -378,6 +378,11 @@ def persist_requests(self, responses, history_path=None):

method, url = res.request.method, res.url
file = self.view.settings().get('requester.file', None)
original_request = None
binding_info = self.view.settings().get('requester.binding_info', None)
if binding_info is not None:
_, original_request = binding_info

key = '{};;{}'.format(req.request, file) if file else req.request
if key in rh:
rh.pop(key, None) # remove duplicate requests
Expand All @@ -390,7 +395,8 @@ def persist_requests(self, responses, history_path=None):
'meta': meta,
'url': url,
'code': res.status_code,
'request': req.request
'request': req.request,
'original_request': original_request,
}

# remove oldest requests if number of requests has exceeded `history_max_entries`
Expand Down
8 changes: 4 additions & 4 deletions docs/_content/body.md
Expand Up @@ -15,8 +15,8 @@ Open a file and insert the following.
requests.get('https://jsonplaceholder.typicode.com/albums')
requests.post('https://jsonplaceholder.typicode.com/albums')

get('https://jsonplaceholder.typicode.com/posts') # 'requests.' prefix is optional
post('jsonplaceholder.typicode.com/posts') # as is the URL scheme
post('https://jsonplaceholder.typicode.com/posts') # 'requests.' prefix is optional
get('jsonplaceholder.typicode.com/posts') # as is the URL scheme
~~~

Place your cursor on one of the lines and hit <kbd>ctrl+alt+r</kbd> (<kbd>ctrl+r</kbd> on macOS). Or, look for __Requester: Run Requests__ in the command palette <kbd>shift+cmd+p</kbd> and hit Enter. A response tab will appear, with a name like __GET: /albums__.
Expand Down Expand Up @@ -324,9 +324,9 @@ Open your keymap from the command palette by running __Preferences: Key Bindings


#### Delete Requests From History
Iterating on a request to get it right can take time. You might inadvertently fill your request history with requests you'd rather not remember.
Iterating on a request to get it right can take time. You might inadvertently fill your request history with requests you'd rather forget.

Fortunately, you can delete these requests from your history by pressing <kbd>ctrl+alt+backspace</kbd> in the request's history tab. For __UNDO__, just replay the request before closing the history tab.
You can delete a request from your history by pressing <kbd>ctrl+alt+backspace</kbd> in the history tab. To undo your delete, just replay the request before closing the history tab.


### Explore Hyperlinked APIs (HATEOAS)
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial.pyr
Expand Up @@ -2,8 +2,8 @@
requests.get('https://jsonplaceholder.typicode.com/albums')
requests.post('https://jsonplaceholder.typicode.com/albums')

get('https://jsonplaceholder.typicode.com/posts') # 'requests.' prefix is optional
post('jsonplaceholder.typicode.com/posts') # as is the URL scheme
post('https://jsonplaceholder.typicode.com/posts') # 'requests.' prefix is optional
get('jsonplaceholder.typicode.com/posts') # as is the URL scheme

"""
Place your cursor on one of the lines above and hit `ctrl+alt+r` (`ctrl+r` on macOS). Or, look for __Requester: Run Requests__ in the command palette and hit Enter. A response tab will appear, with a name like __GET: /albums__.
Expand Down
3 changes: 2 additions & 1 deletion messages.json
Expand Up @@ -30,5 +30,6 @@
"2.19.2": "messages/2.19.2.txt",
"2.20.0": "messages/2.20.0.txt",
"2.21.1": "messages/2.21.1.txt",
"2.22.0": "messages/2.22.0.txt"
"2.22.0": "messages/2.22.0.txt",
"2.23.0": "messages/2.23.0.txt"
}
4 changes: 4 additions & 0 deletions messages/2.23.0.txt
@@ -0,0 +1,4 @@
# New Features
Requests are saved to history with original value of request sent from requester file.

This means saving requests back to requester file works for requests loaded from history, even if these requests were edited in the response tab.

0 comments on commit 7851795

Please sign in to comment.