mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
fixup REFERENCE_TO_PARAGRAPH:
* par id actually can be 0
* properly move on in the buffer list if paragraph is not found
in the current buffer
* use dit to get label (as this might be in a different buffer)
(cherry picked from commit 4ed822925f
)
This commit is contained in:
parent
8fc5266996
commit
0c77174406
@ -1284,7 +1284,7 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
|||||||
|
|
||||||
case LFUN_REFERENCE_TO_PARAGRAPH: {
|
case LFUN_REFERENCE_TO_PARAGRAPH: {
|
||||||
int const id = convert<int>(cmd.getArg(0));
|
int const id = convert<int>(cmd.getArg(0));
|
||||||
flag.setEnabled(id > 0);
|
flag.setEnabled(id >= 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1649,13 +1649,18 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
|
|
||||||
case LFUN_REFERENCE_TO_PARAGRAPH: {
|
case LFUN_REFERENCE_TO_PARAGRAPH: {
|
||||||
int const id = convert<int>(cmd.getArg(0));
|
int const id = convert<int>(cmd.getArg(0));
|
||||||
if (id < 1)
|
if (id < 0)
|
||||||
break;
|
break;
|
||||||
string const type = cmd.getArg(1);
|
string const type = cmd.getArg(1);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Buffer * b = &buffer_; i == 0 || b != &buffer_;
|
for (Buffer * b = &buffer_; i == 0 || b != &buffer_;
|
||||||
b = theBufferList().next(b)) {
|
b = theBufferList().next(b)) {
|
||||||
DocIterator const dit = b->getParFromID(id);
|
DocIterator const dit = b->getParFromID(id);
|
||||||
|
if (dit.empty()) {
|
||||||
|
LYXERR(Debug::INFO, "No matching paragraph found! [" << id << "].");
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
string const label = dit.innerParagraph().getLabelForXRef();
|
string const label = dit.innerParagraph().getLabelForXRef();
|
||||||
if (!label.empty()) {
|
if (!label.empty()) {
|
||||||
// if the paragraph has a label, we refer to this
|
// if the paragraph has a label, we refer to this
|
||||||
@ -1670,7 +1675,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
// we do not want to open the dialog, hence we
|
// we do not want to open the dialog, hence we
|
||||||
// do not employ LFUN_LABEL_INSERT
|
// do not employ LFUN_LABEL_INSERT
|
||||||
InsetCommandParams p(LABEL_CODE);
|
InsetCommandParams p(LABEL_CODE);
|
||||||
docstring const label = cur.getPossibleLabel();
|
docstring const label = dit.getPossibleLabel();
|
||||||
p["name"] = label;
|
p["name"] = label;
|
||||||
string const data = InsetCommand::params2string(p);
|
string const data = InsetCommand::params2string(p);
|
||||||
lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data));
|
lyx::dispatch(FuncRequest(LFUN_INSET_INSERT, data));
|
||||||
|
Loading…
Reference in New Issue
Block a user