Skip to content

Commit

Permalink
Deal with tabs and 2-spaces on auto-add '...'. Fixes #859
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Jan 14, 2023
1 parent 0e1767c commit 5ee8e32
Showing 1 changed file with 102 additions and 5 deletions.
107 changes: 102 additions & 5 deletions robotframework-ls/language-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
["_", "_"]
],
"onEnterRules": [
// Deal with comments to add # when comment is split
{
"beforeText": "^\\s*#.*",
"afterText": ".+$",
Expand All @@ -48,8 +49,74 @@
"appendText": "# "
}
},
// Deal with tabs separators so that the user has: Keyword<tab>|arg1<tab>arg2
// And indent to:
// Keyword<tab>
// ...<tab>|arg1<tab>arg2
{
"beforeText": "^\\s*[^\\s].*",
"beforeText": "^[\\s]*[^\\s]+.*\\t$",
"afterText": "^\\s*[^\\s].*$",
"action": {
"indent": "none",
"appendText": "...\t"
}
},

// Deal with tabs separators so that the user has: Keyword|<tab>arg1<tab>arg2
// And indent to:
// Keyword
// ...<tab>|arg1<tab>arg2
{
"beforeText": "^[\\s]*[^\\s]+.*$",
"afterText": "^\\t\\s*[^\\s].*$",
"action": {
"indent": "none",
"appendText": "..."
}
},

// Deal with 2-spaces separator: Keyword |arg1 arg2
// And indent to:
// Keyword
// ... |arg1 arg2
{
"beforeText": "^([\\s]*[^\\s])+[ ][ ]$",
"afterText": "^[^\\s]+.*$",
"action": {
"indent": "none",
"appendText": "... "
}
},

// Deal with 2-spaces separator: Keyword | arg1 arg2
// And indent to:
// Keyword
// ... | arg1 arg2
{
"beforeText": "^([\\s]*[^\\s])+[ ]$",
"afterText": "^[ ][^\\s]+.*$",
"action": {
"indent": "none",
"appendText": "... "
}
},

// Deal with 2-spaces separator: Keyword| arg1 arg2
// And indent to:
// Keyword
// ...| arg1 arg2
{
"beforeText": "^([\\s]*[^\\s])+$",
"afterText": "^[ ][ ][^\\s]+.*$",
"action": {
"indent": "none",
"appendText": "..."
}
},

// If we didn't match tabs or 2 spaces use 4 spaces for any other spacing mode found.
{
"beforeText": "^[\\s]*[^\\s].*",
"afterText": "^\\s[^\\s].*$",
"action": {
"indent": "none",
Expand Down Expand Up @@ -88,17 +155,47 @@
"appendText": "... "
}
},

// Maybe we'd like to remove the '...' and not add a line at all?
// Anyways, that isn't possible.
// {
// "beforeText": "^\\s*(\\.\\.\\.)(\\s)+$",
// "afterText": ".*$",
// "action": {
// "indent": "none",
// "appendText": ""
// }
// },

// Rules to keep on adding '...' if it starts with '...<spaces or tabs><nonspace>'
// Note: gather feedback (it's nice to not add it always, but then at the last one)
// the user has to erase what was added manually (so, wait for community feedback
// as the vote is out on this one).

// Continuation if it starts with '...<tab><nonspace>'
{
"beforeText": "^\\s*(\\.\\.\\.)(\\s)+$",
"afterText": ".*$",
"beforeText": "^\\s*(\\.\\.\\.)(\\t)(\\s)*[^\\s]+.*",
// "afterText": ".+$",
"action": {
"indent": "none",
"appendText": ""
"appendText": "...\t"
}
},

// Continuation if it starts with '...<space><space><nonspace>'
{
"beforeText": "^\\s*(\\.\\.\\.)[ ][ ][^\\s].*",
// "afterText": ".+$",
"action": {
"indent": "none",
"appendText": "... "
}
},

// Continuation if it starts with '...<sep><nonspace>'
{
"beforeText": "^\\s*(\\.\\.\\.)(\\s)+[^\\s].*",
"afterText": ".*$",
// "afterText": ".+$",
"action": {
"indent": "none",
"appendText": "... "
Expand Down

0 comments on commit 5ee8e32

Please sign in to comment.