minor code fixes, remove key bindings
This commit is contained in:
parent
37759e16bc
commit
f36ac3dde3
|
@ -1,15 +1,15 @@
|
||||||
[
|
[
|
||||||
{
|
// {
|
||||||
"keys": [
|
// "keys": [
|
||||||
"ctrl+alt+j"
|
// "ctrl+alt+j"
|
||||||
],
|
// ],
|
||||||
"command": "pretty_json"
|
// "command": "pretty_json"
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"keys": ["ctrl+r"],
|
// "keys": ["ctrl+r"],
|
||||||
"command": "pretty_json_goto_symbol",
|
// "command": "pretty_json_goto_symbol",
|
||||||
"context": [
|
// "context": [
|
||||||
{ "key": "selector", "operator": "equal", "operand": "source.json" }
|
// { "key": "selector", "operator": "equal", "operand": "source.json" }
|
||||||
]
|
// ]
|
||||||
}
|
// }
|
||||||
]
|
]
|
|
@ -1,15 +1,15 @@
|
||||||
[
|
[
|
||||||
{
|
// {
|
||||||
"keys": [
|
// "keys": [
|
||||||
"super+ctrl+j"
|
// "super+ctrl+j"
|
||||||
],
|
// ],
|
||||||
"command": "pretty_json"
|
// "command": "pretty_json"
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"keys": ["super+r"],
|
// "keys": ["super+r"],
|
||||||
"command": "pretty_json_goto_symbol",
|
// "command": "pretty_json_goto_symbol",
|
||||||
"context": [
|
// "context": [
|
||||||
{ "key": "selector", "operator": "equal", "operand": "source.json" }
|
// { "key": "selector", "operator": "equal", "operand": "source.json" }
|
||||||
]
|
// ]
|
||||||
}
|
// }
|
||||||
]
|
]
|
|
@ -1,22 +1,22 @@
|
||||||
[
|
[
|
||||||
{
|
// {
|
||||||
"keys": [
|
// "keys": [
|
||||||
"ctrl+alt+j"
|
// "ctrl+alt+j"
|
||||||
],
|
// ],
|
||||||
"command": "pretty_json"
|
// "command": "pretty_json"
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"keys": [
|
// "keys": [
|
||||||
"ctrl+alt+m"
|
// "ctrl+alt+m"
|
||||||
],
|
// ],
|
||||||
"command": "un_pretty_json"
|
// "command": "un_pretty_json"
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
"keys": ["ctrl+r"],
|
// "keys": ["ctrl+r"],
|
||||||
"command": "pretty_json_goto_symbol",
|
// "command": "pretty_json_goto_symbol",
|
||||||
"context": [
|
// "context": [
|
||||||
{ "key": "selector", "operator": "equal", "operand": "source.json" }
|
// { "key": "selector", "operator": "equal", "operand": "source.json" }
|
||||||
]
|
// ]
|
||||||
}
|
// }
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -26,7 +26,8 @@
|
||||||
{
|
{
|
||||||
"caption": "Preferences: Pretty JSON Settings",
|
"caption": "Preferences: Pretty JSON Settings",
|
||||||
"command": "edit_settings",
|
"command": "edit_settings",
|
||||||
"args": {
|
"args":
|
||||||
|
{
|
||||||
"base_file": "${packages}/Pretty JSON/Pretty JSON.sublime-settings",
|
"base_file": "${packages}/Pretty JSON/Pretty JSON.sublime-settings",
|
||||||
"default": "{\n\t$0\n}\n"
|
"default": "{\n\t$0\n}\n"
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ class PrettyJsonBaseCommand:
|
||||||
bracket_newline = re.compile(r'^((\s*)".*?":)\s*([\[])', re.MULTILINE)
|
bracket_newline = re.compile(r'^((\s*)".*?":)\s*([\[])', re.MULTILINE)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def json_loads(selection: str, object_pairs_hook=OrderedDict) -> dict:
|
def json_loads(selection: str, object_pairs_hook=OrderedDict):
|
||||||
return json.loads(
|
return json.loads(
|
||||||
selection, object_pairs_hook=object_pairs_hook, parse_float=decimal.Decimal
|
selection, object_pairs_hook=object_pairs_hook, parse_float=decimal.Decimal
|
||||||
)
|
)
|
||||||
|
@ -100,7 +100,7 @@ class PrettyJsonBaseCommand:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_selection_from_region(
|
def get_selection_from_region(
|
||||||
region: sublime.Region, regions_length: int, view: sublime.View
|
region: sublime.Region, regions_length: int, view: sublime.View
|
||||||
) -> sublime.Region:
|
):
|
||||||
entire_file = False
|
entire_file = False
|
||||||
if region.empty() and regions_length > 1:
|
if region.empty() and regions_length > 1:
|
||||||
return None, None
|
return None, None
|
||||||
|
@ -110,9 +110,10 @@ class PrettyJsonBaseCommand:
|
||||||
|
|
||||||
return region, entire_file
|
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())
|
current_line = self.view.line(selection.begin())
|
||||||
text_before_sel = sublime.Region(current_line.begin(), selection.begin())
|
text_before_sel = sublime.Region(current_line.begin(), selection.begin())
|
||||||
|
indent_space = ''
|
||||||
|
|
||||||
reindent_mode = s.get('reindent_block', False)
|
reindent_mode = s.get('reindent_block', False)
|
||||||
if reindent_mode == 'start':
|
if reindent_mode == 'start':
|
||||||
|
@ -371,12 +372,18 @@ class JqQueryPrettyJson(sublime_plugin.WindowCommand):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def is_enabled(self):
|
def is_enabled(self):
|
||||||
|
if not self.window:
|
||||||
|
return
|
||||||
|
|
||||||
as_json = s.get('as_json', ['JSON'])
|
as_json = s.get('as_json', ['JSON'])
|
||||||
return any(
|
return any(
|
||||||
syntax in self.window.active_view().settings().get('syntax') for syntax in as_json
|
syntax in self.window.active_view().settings().get('syntax') for syntax in as_json
|
||||||
)
|
)
|
||||||
|
|
||||||
def is_visible(self):
|
def is_visible(self):
|
||||||
|
if not self.window:
|
||||||
|
return
|
||||||
|
|
||||||
as_json = s.get('as_json', ['JSON'])
|
as_json = s.get('as_json', ['JSON'])
|
||||||
return any(
|
return any(
|
||||||
syntax in self.window.active_view().settings().get('syntax') for syntax in as_json
|
syntax in self.window.active_view().settings().get('syntax') for syntax in as_json
|
||||||
|
@ -423,6 +430,7 @@ class JqQueryPrettyJson(sublime_plugin.WindowCommand):
|
||||||
|
|
||||||
if not PREVIOUS_CONTENT[0]:
|
if not PREVIOUS_CONTENT[0]:
|
||||||
PREVIOUS_CONTENT[0] = raw_json
|
PREVIOUS_CONTENT[0] = raw_json
|
||||||
|
|
||||||
if not PREVIOUS_CONTENT[1]:
|
if not PREVIOUS_CONTENT[1]:
|
||||||
PREVIOUS_CONTENT[1] = raw_json
|
PREVIOUS_CONTENT[1] = raw_json
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue