Skip to content

Commit

Permalink
minor code fixes, remove key bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
TerminalFi committed May 4, 2021
1 parent 37759e1 commit f36ac3d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 49 deletions.
26 changes: 13 additions & 13 deletions Default (Linux).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[
{
"keys": [
"ctrl+alt+j"
],
"command": "pretty_json"
},
{
"keys": ["ctrl+r"],
"command": "pretty_json_goto_symbol",
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.json" }
]
}
// {
// "keys": [
// "ctrl+alt+j"
// ],
// "command": "pretty_json"
// },
// {
// "keys": ["ctrl+r"],
// "command": "pretty_json_goto_symbol",
// "context": [
// { "key": "selector", "operator": "equal", "operand": "source.json" }
// ]
// }
]
26 changes: 13 additions & 13 deletions Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[
{
"keys": [
"super+ctrl+j"
],
"command": "pretty_json"
},
{
"keys": ["super+r"],
"command": "pretty_json_goto_symbol",
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.json" }
]
}
// {
// "keys": [
// "super+ctrl+j"
// ],
// "command": "pretty_json"
// },
// {
// "keys": ["super+r"],
// "command": "pretty_json_goto_symbol",
// "context": [
// { "key": "selector", "operator": "equal", "operand": "source.json" }
// ]
// }
]
38 changes: 19 additions & 19 deletions Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
[
{
"keys": [
"ctrl+alt+j"
],
"command": "pretty_json"
},
{
"keys": [
"ctrl+alt+m"
],
"command": "un_pretty_json"
},
{
"keys": ["ctrl+r"],
"command": "pretty_json_goto_symbol",
"context": [
{ "key": "selector", "operator": "equal", "operand": "source.json" }
]
}
// {
// "keys": [
// "ctrl+alt+j"
// ],
// "command": "pretty_json"
// },
// {
// "keys": [
// "ctrl+alt+m"
// ],
// "command": "un_pretty_json"
// },
// {
// "keys": ["ctrl+r"],
// "command": "pretty_json_goto_symbol",
// "context": [
// { "key": "selector", "operator": "equal", "operand": "source.json" }
// ]
// }

]
3 changes: 2 additions & 1 deletion Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
{
"caption": "Preferences: Pretty JSON Settings",
"command": "edit_settings",
"args": {
"args":
{
"base_file": "${packages}/Pretty JSON/Pretty JSON.sublime-settings",
"default": "{\n\t$0\n}\n"
}
Expand Down
14 changes: 11 additions & 3 deletions PrettyJson.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PrettyJsonBaseCommand:
bracket_newline = re.compile(r'^((\s*)".*?":)\s*([\[])', re.MULTILINE)

@staticmethod
def json_loads(selection: str, object_pairs_hook=OrderedDict) -> dict:
def json_loads(selection: str, object_pairs_hook=OrderedDict):
return json.loads(
selection, object_pairs_hook=object_pairs_hook, parse_float=decimal.Decimal
)
Expand Down Expand Up @@ -100,7 +100,7 @@ def json_dumps(obj, minified: bool = False) -> str:
@staticmethod
def get_selection_from_region(
region: sublime.Region, regions_length: int, view: sublime.View
) -> sublime.Region:
):
entire_file = False
if region.empty() and regions_length > 1:
return None, None
Expand All @@ -110,9 +110,10 @@ def get_selection_from_region(

return region, entire_file

def reindent(self, text: str, selection: str):
def reindent(self, text: str, selection: sublime.Region):
current_line = self.view.line(selection.begin())
text_before_sel = sublime.Region(current_line.begin(), selection.begin())
indent_space = ''

reindent_mode = s.get('reindent_block', False)
if reindent_mode == 'start':
Expand Down Expand Up @@ -371,12 +372,18 @@ class JqQueryPrettyJson(sublime_plugin.WindowCommand):
"""

def is_enabled(self):
if not self.window:
return

as_json = s.get('as_json', ['JSON'])
return any(
syntax in self.window.active_view().settings().get('syntax') for syntax in as_json
)

def is_visible(self):
if not self.window:
return

as_json = s.get('as_json', ['JSON'])
return any(
syntax in self.window.active_view().settings().get('syntax') for syntax in as_json
Expand Down Expand Up @@ -423,6 +430,7 @@ def send_query(self, query: str):

if not PREVIOUS_CONTENT[0]:
PREVIOUS_CONTENT[0] = raw_json

if not PREVIOUS_CONTENT[1]:
PREVIOUS_CONTENT[1] = raw_json

Expand Down

5 comments on commit f36ac3d

@sharunkumar
Copy link
Contributor

Choose a reason for hiding this comment

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

Why were keybindings removed? 🤔

@TerminalFi
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Keybindings should be a user leave setting and it conflicted with a number of other packages.

@WisZhou
Copy link

@WisZhou WisZhou commented on f36ac3d Jun 4, 2021

Choose a reason for hiding this comment

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

A list of commands should be provided, and it took me a long time to guess the commands needed.

@sharunkumar
Copy link
Contributor

Choose a reason for hiding this comment

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

A list of commands should be provided, and it took me a long time to guess the commands needed.

#143

@TerminalFi
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree. I will get this fixed

Please sign in to comment.