Comments (10)
I found a case, why error presented:
( code from luajit-remake )
static void NO_RETURN HandleMetatableSlowPath(TValue tvIndex, TValue base, TValue metamethod) {
while (true) {
// Calling plugin ':TSJSplit' when cursor at 'likely' { row 9, col 13 }.
// The 'if_statement' NOT configured with "{ target_nodes = { 'compound_statement' } }".
// TreeSJ continue search for suitable node up and found 'compound_statement' at line(row) 2.
// 'compound_statement' is already splitted. Repeated split (without "split = { recursive = true }")
// is joining all nested multiline node to one line.
if (likely(metamethod.Is<tHeapEntity>())) {
HeapEntityType mmType = metamethod.GetHeapEntityType();
if (mmType == HeapEntityType::Function) {
MakeCall(metamethod.As<tFunction>(), base, tvIndex,
GlobalGetMetamethodCallContinuation);
} else if (mmType == HeapEntityType::Table) {
assert(tvIndex.Is<tString>());
HeapPtr<HeapString> index = tvIndex.As<tString>();
HeapPtr<TableObject> tableObj = metamethod.As<tTable>();
GetByIdICInfo icInfo;
TableObject::PrepareGetById(
tableObj, UserHeapPointer<HeapString>{index}, icInfo /*out*/);
TValue result = TableObject::GetById(tableObj, index, icInfo);
if (likely(!icInfo.m_mayHaveMetatable || !result.Is<tNil>())) {
Return(result);
}
EnterSlowPath<CheckMetatableSlowPath>(tableObj);
}
}
}
}
When trying 'split' already split block, sticky-cursor work wrong. I'll think, how correctly handle this. At the moment, I just hide error with safe calling.
from treesj.
It cannot detect 'if_statement' outside 'if_statement'. And I don't understand for why it can be need? :-) Here, plugin found a
compound_statement
of function because it is the closest suitable node. See 'How it works' in readme.You can strongly restrict split/join 'compound_statement' if it contains 'if_statement':
local cpp = { compound_statement = u.set_preset_for_list({ both = { separator = ';', last_separator = true, no_format_with = { 'if_statement' }, }, }), if_statement = { target_nodes = { 'compound_statement' } }, }
I see, should have studied the README.md more :'). Thank you!
Although, Ive seen to be a better/more general config:
local cpp = {
compound_statement = u.set_preset_for_statement({
both = {
separator = ';',
last_separator = true,
no_format_with = { 'compound_statement' },
},
}),
if_statement = { target_nodes = { 'compound_statement' } },
}
In my plan, implement functionality, when it will be able to configure same node the different depending on the context. Maybe it will solve it task.
YES! this would definitely give more control to the user as well as the plugin itself! I vote its a good feature to add.
Ill go update the overall config ive found to be generally useful for Cpp / Python in PRs!
from treesj.
YES! this would definitely give more control to the user as well as the plugin itself! I vote its a good feature to add. Ill go update the overall config ive found to be generally useful for Cpp / Python in PRs!
Excellent! Please, add tests in a PR according to 'tests/README.md'
from treesj.
I can't reproduce this bug. Maybe you're calling plugin when this fragment inside another node and the error happen on it?
Nevertheless, I will look for the error. Thanks for helpings.
cpp.mov
from treesj.
Hey! I cannot reproduce the bug either anymore, it might be I was on an older version of plugin or something. But you have given me a workable idea:
Is it possible to only affect the compound_statements
inside an if_statement
, not in general?
Because this config (as can be seen in your comment), will change the entire function if im outside an if_statement
because it is a compound_statement
.
Some nodes can be seen to have names
as well in TS Playground, can these names/titles be supported in TreesJ, not just the name of the node?
Eg: In the code sample we are discussing, if_clause
has 2 compound_statements
inside, one with name consequence
and other with alternative
. It would be trivial if these names could be used instead of the general compound_statement
.
from treesj.
Is it possible to only affect the
compound_statements
inside anif_statement
, not in general?
Not sure what I correctly understood your question, but '{ target_nodes = { ... } }' just for it.
Some nodes can be seen to have
names
as well in TS Playground, can these names/titles be supported in TreesJ, not just the name of the node?
Hmm, you mean like it configured in javascript for try_statement
what contains few statement_block
in catch_clause
and finaly_clause
?
from treesj.
Some nodes can be seen to have
names
as well in TS Playground, can these names/titles be supported in TreesJ, not just the name of the node?Hmm, you mean like it configured in javascript for
try_statement
what contains fewstatement_block
incatch_clause
andfinaly_clause
?
Like in this setup, can the red highlighted condition
and consequence
and alternative
be added as nodes to the config? EG:
javascript = {
-- is this possible?
condition = { --[[ ]] },
consequence = { --[[ ]] },
alternative = { --[[ ]] },
-- instead of this
statement_block = { -- [[ ]] },
parenthesized_expression = { --[[ ]] },
else_clause = { -- [[ ]] }
}
this way, only say condition
node for if_statement
will be effect, not any other parenthesized_expression
nodes in the program.
Is it possible to only affect the
compound_statements
inside anif_statement
, not in general?Not sure what I correctly understood your question, but '{ target_nodes = { ... } }' just for it.
this is related to the above as well.
Basically, the problem im facing is:
upload.mov
IE: with the config:
cpp = {
compound_statement = treesj_utils.set_preset_for_list({
both = {
separator = ';',
last_separator = true,
no_format_with = {}
}
}),
if_statement = { target_nodes = { 'compound_statement' }}
}
Split/Join
work perfectly when on/inside the if_statement
.
But Split
when outside the if_statement
, but still inside the function body (which itself is a compound_statement
), will destroy the formatting of the function body, and also place the cursor at a seemingly weird position. Join
in this case makes the function body in one line.
I hope to achieve the behavior where, if_statement
still works the same as above,
but calling Split/Join
has no effect when outside if_statement
.
This can be made possible, as I mention in the previous reply:
If we can just add configs for consequence
which is specific, but no need for compound_statement
which is general.
from treesj.
It cannot detect 'if_statement' outside 'if_statement'. And I don't understand for why it can be need? :-) Here, plugin found a compound_statement
of function because it is the closest suitable node. See 'How it works' in readme.
You can strongly restrict split/join 'compound_statement' if it contains 'if_statement':
local cpp = {
compound_statement = u.set_preset_for_list({
both = {
separator = ';',
last_separator = true,
no_format_with = { 'if_statement' },
},
}),
if_statement = { target_nodes = { 'compound_statement' } },
}
In my plan, implement functionality, when it will be able to configure same node the different depending on the context. Maybe it will solve it task.
from treesj.
Keeping issue open till original error is resolved.
from treesj.
Fixed in #18
from treesj.
Related Issues (20)
- Allow fallback when no node is found HOT 2
- Adds semicolon at the end of function declarations in Rust
- [BUG] Incorrect behaviour for toggling Ruby blocks HOT 2
- Join adds unnecessary space for empty Lua table HOT 1
- Join adds unnecessary commas and spaces, in Python HOT 2
- [Feature Request]: Toggle between <a></a> and <a /> (if tag is empty) in HTML/JSX etc. HOT 1
- Paranthesized expression support for Rust HOT 1
- Fix tests that fail
- module 'treesj' not found HOT 2
- FR: when on comment, just run `gqq` HOT 9
- Can only split/join/toggle once HOT 11
- Cant disable the preset keybindings. HOT 4
- Typescript: Split/Join some arrow functions results in invalid code HOT 1
- Error when Running Lua Config from README
- [TreeSJ]: Cannot join "table_constructor" containing node from one of this: { "commend" } HOT 3
- Allow ignoring the max join length for single calls HOT 1
- Fallback to `mini.splitjoin` HOT 2
- [golang] "The current node is already splitted" when attempting to split a multiline statement HOT 1
- JS/TS: split-join should support curly-less if statements HOT 2
- Is `nvim-treesitter` still a dependency? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from treesj.