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箇所コメントアウトしてます。

[
  // 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 }
    ]
  }
]


0 件のコメント:

コメントを投稿