2013年7月26日金曜日

SublimeText2とGoogle日本語入力を使用して、日本語コメントを入力してENTER押すと消える問題(長っ


タイトルどおりです。
問題はどういうことかというと、日本語コメント入力して、



ENTER押すと・・・・




消えた・・・\(^o^)/

おそらくはコメント行を自動で補完してくれる優しさが日本語に上書きされるのが問題だと思われます。

ググったらやさしい方がGitHubに回避方法を公開していました。
http://koizuss.hatenablog.com/entry/2013/01/14/112350
https://gist.github.com/koizuss/4521934
お、Default.sublime-keymapの36行から3つ分をコメントすればいいみたい。
やっほい!

Default.sublime-keymapはSublimeを立ち上げて、
 Preference > Browse Packages...
から、
/Packages/DocBlockr/Default.sublime-keymap
で開ける。


・・・
・・・・・・
直らない・・・・

結局設定を読んでいるともう一箇所コメントしないといけないことに気づく。
コメントアウトしたら上記の問題が回避できた。

結局、設定はこのようになりました↓
合計4箇所コメントアウトしてます。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
[
  // open a docblock with enter
  { "keys": ["enter"], "command": "jsdocs",
    "context": [
      { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,                    "match_all": true },
      { "key": "selection_empty",       "operator": "equal",          "operand": true,                    "match_all": true },
      { "key": "auto_complete_visible", "operator": "equal",          "operand": false,                   "match_all": true },
      { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*(\\/\\*|###)\\*$", "match_all": true }
    ]
  },
  // open a docblock with keypad enter
  { "keys": ["keypad_enter"], "command": "jsdocs",
    "context": [
      { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,                    "match_all": true },
      { "key": "selection_empty",       "operator": "equal",          "operand": true,                    "match_all": true },
      { "key": "auto_complete_visible", "operator": "equal",          "operand": false,                   "match_all": true },
      { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*(\\/\\*|###)\\*$", "match_all": true }
    ]
  },
  // open a docblock with tab
  { "keys": ["tab"], "command": "jsdocs",
    "context": [
      { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,                    "match_all": true },
      { "key": "selection_empty",       "operator": "equal",          "operand": true,                    "match_all": true },
      { "key": "auto_complete_visible", "operator": "equal",          "operand": false,                   "match_all": true },
      { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*(\\/\\*|###)\\*$", "match_all": true }
    ]
  },
 
  /**
   * Google日本語入力を使っている場合のENTERで入力内容が消える問題に対応
   * ↓をコメントアウトすることでとりあえず入力できるようになる
   * (Docコメント内で改行しても整形されなくなる)
   */
 
  // // extend a docblock by adding an asterisk at the start
  // { "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n${TM_CURRENT_LINE/^\\s*(\\*\\s*).*$/$1/}"},
  //   "context": [
  //     { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,              "match_all": true },
  //     { "key": "selector",              "operator": "equal",          "operand": "comment.block",   "match_all": true },
  //     { "key": "auto_complete_visible", "operator": "equal",          "operand": false,             "match_all": true },
  //     { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*\\*\\s*\\S", "match_all": true }
  //   ]
  // },
  // // extend a docblock by adding an asterisk at the start
  // { "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n${TM_CURRENT_LINE/^\\s*(\\*\\s*).*$/$1/}"},
  //   "context": [
  //     { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,            "match_all": true },
  //     { "key": "selector",              "operator": "equal",          "operand": "comment.block", "match_all": true },
  //     { "key": "auto_complete_visible", "operator": "equal",          "operand": false,           "match_all": true },
  //     { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*\\*",      "match_all": true }
  //   ]
  // },
  // // extend a docblock with keypad enter by adding an asterisk at the start
  // { "keys": ["keypad_enter"], "command": "insert_snippet", "args": {"contents": "\n${TM_CURRENT_LINE/^\\s*(\\*\\s*).*$/$1/}"},
  //   "context": [
  //     { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,            "match_all": true },
  //     { "key": "selector",              "operator": "equal",          "operand": "comment.block", "match_all": true },
  //     { "key": "auto_complete_visible", "operator": "equal",          "operand": false,           "match_all": true },
  //     { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*\\*",      "match_all": true }
  //   ]
  // },
 
  // trim the automatically added whitespace
  { "keys": ["enter"], "command": "jsdocs_trim_auto_whitespace",
    "context": [
      { "key": "setting.auto_indent",                "operator": "equal",          "operand": true,            "match_all": true },
      { "key": "selector",                           "operator": "equal",          "operand": "comment.block", "match_all": true },
      { "key": "auto_complete_visible",              "operator": "equal",          "operand": false,           "match_all": true },
      { "key": "setting.trim_automatic_white_space", "operator": "equal",          "operand": true,            "match_all": true },
      { "key": "preceding_text",                     "operator": "regex_contains", "operand": "^\\s*\\*\\s*$", "match_all": true },
      { "key": "following_text",                     "operator": "regex_contains", "operand": "^\\s*$",        "match_all": true }
    ]
  },
  // trim the automatically added whitespace
  { "keys": ["keypad_enter"], "command": "jsdocs_trim_auto_whitespace",
    "context": [
      { "key": "setting.auto_indent",                "operator": "equal",          "operand": true,            "match_all": true },
      { "key": "selector",                           "operator": "equal",          "operand": "comment.block", "match_all": true },
      { "key": "auto_complete_visible",              "operator": "equal",          "operand": false,           "match_all": true },
      { "key": "setting.trim_automatic_white_space", "operator": "equal",          "operand": true,            "match_all": true },
      { "key": "preceding_text",                     "operator": "regex_contains", "operand": "^\\s*\\*\\s*$", "match_all": true },
      { "key": "following_text",                     "operator": "regex_contains", "operand": "^\\s*$",        "match_all": true }
    ]
  },
  // extend line comments (// and #)
  /**
   * ここでENTERキーを押してもコメントの行が自動補完されないようにする。
   */
//  { "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n${TM_CURRENT_LINE/^\\s*((?:#|\\/\\/)\\s*).*/$1/}"},
//    "context": [
//      { "key": "setting.auto_indent",                "operator": "equal",          "operand": true,              "match_all": true },
//      { "key": "setting.jsdocs_extend_double_slash", "operator": "equal",          "operand": true,              "match_all": true },
//      { "key": "selector",                           "operator": "equal",          "operand": "comment.line",    "match_all": true },
//      { "key": "auto_complete_visible",              "operator": "equal",          "operand": false,             "match_all": true },
//      { "key": "preceding_text",                     "operator": "regex_contains", "operand": "^\\s*(\\/\\/|#)", "match_all": true }
//    ]
//  },
  // extend line comments (// #) with keypad enter
  { "keys": ["keypad_enter"], "command": "insert_snippet", "args": {"contents": "\n${TM_CURRENT_LINE/^\\s*((?:#|\\/\\/)\\s*).*$/$1/}"},
    "context": [
      { "key": "setting.auto_indent",                "operator": "equal",          "operand": true,           "match_all": true },
      { "key": "setting.jsdocs_extend_double_slash", "operator": "equal",          "operand": true,           "match_all": true },
      { "key": "selector",                           "operator": "equal",          "operand": "comment.line", "match_all": true },
      { "key": "auto_complete_visible",              "operator": "equal",          "operand": false,          "match_all": true },
      { "key": "preceding_text",                     "operator": "regex_contains", "operand": "^\\s*\\/\\/",  "match_all": true }
    ]
  },
  // close a block comment (/*  */)
  { "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n$0\n */"},
    "context": [
      { "key": "selection_empty", "operator": "equal",          "operand": true,           "match_all": true },
      { "key": "preceding_text",  "operator": "regex_contains", "operand": "^\\s*\\/\\*$", "match_all": true }
    ]
  },
  // close a block comment (/*  */)
  { "keys": ["keypad_enter"], "command": "insert_snippet", "args": {"contents": "\n$0\n */"},
    "context": [
      { "key": "selection_empty", "operator": "equal",          "operand": true,           "match_all": true },
      { "key": "preceding_text",  "operator": "regex_contains", "operand": "^\\s*\\/\\*$", "match_all": true }
    ]
  },
  { "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n$0\n "}, "context":
    [
      { "key": "selection_empty", "operator": "equal",          "operand": true,           "match_all": true},
      { "key": "preceding_text",  "operator": "regex_contains", "operand": "^\\s*\\/\\*$", "match_all": true},
      { "key": "following_text",  "operator": "regex_contains", "operand": "^\\*\\/\\s*$", "match_all": true}
    ]
  },
  { "keys": ["keypad_enter"], "command": "insert_snippet", "args": {"contents": "\n$0\n "}, "context":
    [
      { "key": "selection_empty", "operator": "equal",          "operand": true,           "match_all": true},
      { "key": "preceding_text",  "operator": "regex_contains", "operand": "^\\s*\\/\\*$", "match_all": true},
      { "key": "following_text",  "operator": "regex_contains", "operand": "^\\*\\/$",     "match_all": true}
    ]
  },
  // De-indent at the end of a comment block
  { "keys": ["enter"], "command": "jsdocs_deindent",
    "context": [
      { "key": "selection_empty", "operator": "equal",          "operand": true,        "match_all": true },
      { "key": "preceding_text",  "operator": "regex_contains", "operand": "^\\s+\\*/", "match_all": true }
    ]
  },
  // de-indent at the end of a comment block with keypad-enter
  { "keys": ["keypad_enter"], "command": "jsdocs_deindent",
    "context": [
      { "key": "selection_empty", "operator": "equal",          "operand": true,        "match_all": true },
      { "key": "preceding_text",  "operator": "regex_contains", "operand": "^\\s+\\*/", "match_all": true }
    ]
  },
  // Open an inline docblock (/** */)
  { "keys": ["shift+enter"], "command": "jsdocs", "args": {"inline": true},
    "context": [
      { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,              "match_all": true },
      { "key": "selection_empty",       "operator": "equal",          "operand": true,              "match_all": true },
      { "key": "auto_complete_visible", "operator": "equal",          "operand": false,             "match_all": true },
      { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*\\/\\*{2}$", "match_all": true }
    ]
  },
  // Open an inline docblock
  { "keys": ["shift+keypad_enter"], "command": "jsdocs", "args": {"inline": true},
    "context": [
      { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,              "match_all": true },
      { "key": "selection_empty",       "operator": "equal",          "operand": true,              "match_all": true },
      { "key": "auto_complete_visible", "operator": "equal",          "operand": false,             "match_all": true },
      { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*\\/\\*{2}$", "match_all": true }
    ]
  },
  // show the autocomplete
  { "keys": ["@"], "command": "run_macro_file", "args": {"file": "Packages/DocBlockr/jsdocs-auto-complete.sublime-macro"},
    "context": [
      { "key": "setting.auto_complete", "operator": "equal",    "operand": true,                           "match_all": true },
      { "key": "selection_empty", "operator": "equal",          "operand": true,                           "match_all": true },
      { "key": "preceding_text",  "operator": "regex_contains", "operand": "^\\s*(?:\\/\\*|###)?\\*\\s*$", "match_all": true },
      { "key": "selector",        "operator": "equal",          "operand": "comment.block",                "match_all": true }
    ]
  },
  // show the autocomplete in a coffee doc block
  { "keys": ["@"], "command": "run_macro_file", "args": {"file": "Packages/DocBlockr/jsdocs-auto-complete.sublime-macro"},
    "context": [
      { "key": "selection_empty", "operator": "equal",          "operand": true,                              "match_all": true },
      { "key": "preceding_text",  "operator": "regex_contains", "operand": "^\\s*#\\s*$",                     "match_all": true },
      { "key": "selector",        "operator": "equal",          "operand": "comment.line.number-sign.coffee", "match_all": true }
    ]
  },
  // indent to align with the previous line
  { "keys": ["tab"], "command": "jsdocs_indent",
    "context": [
      { "key": "setting.jsdocs_deep_indent", "operator": "equal",          "operand": true,            "match_all": true },
      { "key": "setting.auto_indent",        "operator": "equal",          "operand": true,            "match_all": true },
      { "key": "selection_empty",            "operator": "equal",          "operand": true,            "match_all": true },
      { "key": "preceding_text",             "operator": "regex_contains", "operand": "^\\s*\\*\\s*$", "match_all": true },
      { "key": "selector",                   "operator": "equal",          "operand": "comment.block", "match_all": true }
    ]
  },
  // decorate a double-slash comment
  { "keys": ["ctrl+enter"], "command": "jsdocs_decorate",
    "context": [
      { "key": "selector", "operator": "equal", "operand": "comment.line.double-slash"}
    ]
  },
  // decorate a double-slash comment
  { "keys": ["ctrl+keypad_enter"], "command": "jsdocs_decorate",
    "context": [
      { "key": "selector", "operator": "equal", "operand": "comment.line.double-slash"}
    ]
  },
  // join lines inside a comment block, stripping the leading asterisk
  { "keys": ["ctrl+j"], "command": "jsdocs_join",
    "context": [
      { "key": "selector", "operator": "equal", "operand": "comment.block" }
    ]
  },
  // join lines in a line comment, stripping the leading // or #
  { "keys": ["ctrl+j"], "command": "jsdocs_join",
    "context": [
      { "key": "selector", "operator": "equal", "operand": "comment.line" }
    ]
  },
  // reparse a comment block's placeholders
  { "keys": ["ctrl+alt+tab"], "command": "jsdocs_reparse",
    "context": [
      { "key": "selector", "operator": "equal", "operand": "comment.block" }
    ]
  },
  { "keys": ["alt+q"], "command": "jsdocs_wrap_lines",
    "context": [
      { "key": "selector", "operator": "equal", "operand": "comment.block", "match_all": true }
    ]
  },
 
  // add line after, in a DocBlock
  { "keys": ["ctrl+enter"], "command": "run_macro_file", "args": {"file": "Packages/DocBlockr/Add DocBlockr Line.sublime-macro"},
    "context": [
      { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,            "match_all": true },
      { "key": "selector",              "operator": "equal",          "operand": "comment.block", "match_all": true },
      { "key": "auto_complete_visible", "operator": "equal",          "operand": false,           "match_all": true },
      { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*\\*",      "match_all": true }
    ]
  },
 
  // add line before, in a DocBlock
  { "keys": ["ctrl+shift+enter"], "command": "run_macro_file", "args": {"file": "Packages/DocBlockr/Add DocBlockr Line Before.sublime-macro"},
    "context": [
      { "key": "setting.auto_indent",   "operator": "equal",          "operand": true,            "match_all": true },
      { "key": "selector",              "operator": "equal",          "operand": "comment.block", "match_all": true },
      { "key": "auto_complete_visible", "operator": "equal",          "operand": false,           "match_all": true },
      { "key": "preceding_text",        "operator": "regex_contains", "operand": "^\\s*\\*",      "match_all": true }
    ]
  }
]