- string selection = string();
- if (fl_get_button(dialog_->check_fullpath)) {
- // contents in browser has full path
- selection = getString(dialog_->browser);
- } else {
- // contents in browser has filenames without path
- // reconstruct path from controller getContents
- string const files = controller().getContents(activeStyle, true);
- vector<string> const vec = getVectorFromString(files, "\n");
-
- // find line in files vector
- vector<string>::const_iterator it = vec.begin();
- int const line = fl_get_browser(dialog_->browser);
- for (int i = line; it != vec.end() && i > 0; ++it, --i) {
- if (i == 1) selection = *it;
- }
- }
-
- if (!selection.empty()) {
- controller().viewFile(selection);
- }
-
- // reset the browser so that the following single-click callback doesn't do anything
+ ContentsType::size_type const sel = fl_get_browser(ob);
+ ContentsType const & data = texdata_[activeStyle];
+ string file = data[sel-1];
+ if (!fl_get_button(dialog_->check_fullpath))
+ file = getTexFileFromList(data[sel-1],
+ controller().getFileType(activeStyle));
+ if (sel >= 1 && sel <= data.size())
+ controller().viewFile(file);
+
+ // reset the browser so that the following single-click
+ // callback doesn't do anything